-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimes-Generator.m
57 lines (52 loc) · 914 Bytes
/
Primes-Generator.m
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
indice = 1;
a = 800001;
delta = 800099 - 800001;
d = delta/2;
for i =1:5
z = randi([0, d]);
number(i) = a + 2*z +1;
end
%x = number(1);
for x = 3:2:number(1)
y = 3;
isprime = true;
while (y<=sqrt(x))
%disp(x)
%disp(y)
%disp(mod(x,y))
if (mod(x,y) == 0 || mod(x,2) == 0)
isprime = false;
break
end
y = y + 1;
end
if isprime == true
primos(indice)= x;
indice = indice + 1;
end
end
disp(primos)
i=1;
tamanho=size(primos);
%for j = 1:tamanho
resultado1=[];
resultado2=[];
n=1
%fori=1;
tamanho=size(primos);
%for j = 1:tamanho
j=tamanho(2);
%for r = 1:5
for j = tamanho(2):-1:1
while (primos(j)+primos(i)<=800044)
disp(primos(j)+primos(i))
if (primos(j)+primos(i))==800044
resultado1(n) = primos(j);
resultado2(n)= primos(i);
n=n+1;
end
i=i+1;
end
%disp(i)
end
%end