Prime conspiracy: Difference between revisions
Content added Content deleted
(→{{header|PARI/GP}}: format the pari/gp code) |
(Added Easylang) |
||
Line 755: | Line 755: | ||
9 -> 7 count: 58130 frequency: 5.81% |
9 -> 7 count: 58130 frequency: 5.81% |
||
9 -> 9 count: 42843 frequency: 4.28%</pre> |
9 -> 9 count: 42843 frequency: 4.28%</pre> |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight> |
|||
fastfunc isprim num . |
|||
# test only odd numbers |
|||
i = 3 |
|||
while i <= sqrt num |
|||
if num mod i = 0 |
|||
return 0 |
|||
. |
|||
i += 2 |
|||
. |
|||
return 1 |
|||
. |
|||
func nextprim num . |
|||
repeat |
|||
num += 2 |
|||
until isprim num = 1 |
|||
. |
|||
return num |
|||
. |
|||
len d[][] 9 |
|||
for i to 9 |
|||
len d[i][] 9 |
|||
. |
|||
d[2][3] = 1 |
|||
p = 3 |
|||
for i to 1000000 |
|||
pp = p |
|||
p = nextprim p |
|||
d[pp mod 10][p mod 10] += 1 |
|||
. |
|||
for i to 9 |
|||
for j to 9 |
|||
if d[i][j] > 0 |
|||
print i & " -> " & j & ": " & d[i][j] & " = " & d[i][j] / 10000 & "%" |
|||
. |
|||
. |
|||
. |
|||
</syntaxhighlight> |
|||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |