Prime conspiracy: Difference between revisions
→{{header|PARI/GP}}: format the pari/gp code
m (→{{header|Wren}}: Minor tidy.) |
(→{{header|PARI/GP}}: format the pari/gp code) |
||
Line 2,076:
<syntaxhighlight lang="parigp">
conspiracy(maxx) = {
print("primes considered= ", maxx);
x = matrix(9, 9)
p = 2;
cnt+=1;▼
p=nextprime(p+1);▼
while (cnt <= maxx,
▲q= p%10;
▲ cnt += 1;
m = q;
▲ p = nextprime(p + 1);
forstep(i=1,9,2,▼
q = p % 10;
forstep(j=1,9,2,▼
x[m, q] += 1
if( x[i,j]<1,continue);▼
);
print ("total transitions= ",cnt);▼
printf("2 to 3 count: %d freq %.6f %s\n", x[2, 3], 100. *x[2,3]/cnt, "%");
print(p);▼
▲ forstep(i = 1, 9, 2,
▲ forstep(j = 1, 9, 2,
printf("%d to %d count: %d freq %.6f %s\n", i, j, x[i, j], 100. *x[i,j]/cnt, "%");
)
);
▲ print(p);
}
conspiracy(1000000);
</syntaxhighlight>
{{Out}}
<syntaxhighlight lang="parigp">
primes considered= 1000000
2 to 3 count: 1
1 to 1 count: 42853
1 to 3 count: 77475
1 to 5 count: 0
1 to 7 count: 79453
1 to 9 count: 50153
3 to 1 count: 58255
3 to 3 count: 39668
3 to 5 count: 1
3 to 7 count: 72828
3 to 9 count: 79358
5 to 1 count: 0
5 to 3 count: 0
5 to 5 count: 0
5 to 7 count: 1
5 to 9 count: 0
7 to 1 count: 64230
7 to 3 count: 68595
7 to 5 count: 0
7 to 7 count: 39604
7 to 9 count: 77586
9 to 1 count: 84596
9 to 3 count: 64371
9 to 5 count: 0
9 to 7 count: 58130
9 to 9 count: 42843
total transitions= 1000001
15485917
</syntaxhighlight>
|