-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepresent-n_p-Graph.jl
101 lines (82 loc) · 2.27 KB
/
Represent-n_p-Graph.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using Plots
using Base64
param_n = parse(Int, ARGS[1])
function is_prime(n::Int)
if n <= 1
return false
elseif n <= 3
return true
end
if n % 2 == 0 || n % 3 == 0
return false
end
i = 5
while i * i <= n
if n % i == 0 || n % (i + 2) == 0
return false
end
i = i + 6
end
return true
end
graph_x = []
graph_y = []
for loop_n in 2:param_n
global graph_x
global graph_y
All_Prime_Sequence = []
Prime_Sequence = []
for i in 1:loop_n
# global Prime_Sequence
if is_prime(i) == true
push!(Prime_Sequence, i)
end
end
push!(All_Prime_Sequence, Prime_Sequence)
# println(string(Prime_Sequence) * "\n")
while true
# global Prime_Sequence
# global All_Prime_Sequence
if length(Prime_Sequence) == 1
push!(graph_x, loop_n)
push!(graph_y, Prime_Sequence[1])
break
end
new_prime_sequence = []
for i in 1:length(Prime_Sequence)
if is_prime(i) == true
push!(new_prime_sequence, Prime_Sequence[i])
end
end
Prime_Sequence = new_prime_sequence
push!(All_Prime_Sequence, Prime_Sequence)
# println(string(Prime_Sequence) * "\n")
end
end
println("========================================================================================")
Last_Primes_Array = []
for i in 1:length(graph_y)
if (graph_y[i] in Last_Primes_Array) == false
push!(Last_Primes_Array, graph_y[i])
end
end
println("Last Primes Array")
println(Last_Primes_Array)
println("========================================================================================")
# println("The Number Of Sequences : " * string(length(All_Prime_Sequence)))
# for i in 1:length(All_Prime_Sequence)
# print(string(length(All_Prime_Sequence[i])) * " ")
# end
plot(graph_x, graph_y,
marker = :circle,
linestyle = :solid,
label = "n과 p에 대한 그래프",
title = "n과 p에 대한 그래프",
xlabel = "n ( 소수 범위 n )",
ylabel = "Last Prime Number ( 마지막 소수 )")
savefig("n_p-graph.png")
graph_image = read("n_p-graph.png")
encoded_graph_image = base64encode(graph_image)
data_url = "data:image/png;base64,$encoded_graph_image"
println("========================================================================================")
println(data_url)