Safe primes and unsafe primes: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
 
Line 1,028:
Count = 633,922
Elapsed Time: 816.075 ms.
</pre>
 
=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
fastfunc isprim num .
if num < 2
return 0
.
if num mod 2 = 0
if num = 2
return 1
.
return 0
.
i = 3
while i <= sqrt num
if num mod i = 0
return 0
.
i += 2
.
return 1
.
print "First 35 safe primes:"
for i = 2 to 999999
if isprim i = 1 and isprim ((i - 1) / 2) = 1
if count < 35
write i & " "
.
count += 1
.
.
print ""
print "There are " & count & " safe primes below 1000000"
for i = i to 9999999
if isprim i = 1 and isprim ((i - 1) / 2) = 1
count += 1
.
.
print "There are " & count & " safe primes below 10000000"
print ""
count = 0
print "First 40 unsafe primes:"
for i = 2 to 999999
if isprim i = 1 and isprim ((i - 1) / 2) = 0
if count < 40
write i & " "
.
count += 1
.
.
print ""
print "There are " & count & " unsafe primes below 1000000"
for i = i to 9999999
if isprim i = 1 and isprim ((i - 1) / 2) = 0
count += 1
.
.
print "There are " & count & " unsafe primes below 10000000"
</syntaxhighlight>
 
{{out}}
<pre>
First 35 safe primes:
5 7 11 23 47 59 83 107 167 179 227 263 347 359 383 467 479 503 563 587 719 839 863 887 983 1019 1187 1283 1307 1319 1367 1439 1487 1523 1619
There are 4324 safe primes below 1000000
There are 30657 safe primes below 10000000
 
First 40 unsafe primes:
2 3 13 17 19 29 31 37 41 43 53 61 67 71 73 79 89 97 101 103 109 113 127 131 137 139 149 151 157 163 173 181 191 193 197 199 211 223 229 233
There are 74174 unsafe primes below 1000000
There are 633922 unsafe primes below 10000000
</pre>
 
1,982

edits