Triplet of three numbers: Difference between revisions

Added XPL0 example.
(Added 11l)
(Added XPL0 example.)
Line 2,284:
 
Found 46 such numbers.
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
[if rem(N/I) = 0 then return false;
I:= I+1;
];
return true;
];
 
int Count, N;
[ChOut(0, ^ );
Count:= 0;
for N:= 3 to 6000-1 do
if IsPrime(N-1) & IsPrime(N+3) & IsPrime(N+5) then
[IntOut(0, N-1); ChOut(0, ^ );
IntOut(0, N+3); ChOut(0, ^ );
IntOut(0, N+5); ChOut(0, ^ );
Count:= Count+1;
if rem(Count/5) then ChOut(0, 9\tab\) else CrLf(0);
];
CrLf(0);
IntOut(0, Count);
Text(0, " prime triplets found below 6000.
");
]</lang>
 
{{out}}
<pre>
7 11 13 13 17 19 37 41 43 67 71 73 97 101 103
103 107 109 193 197 199 223 227 229 277 281 283 307 311 313
457 461 463 613 617 619 823 827 829 853 857 859 877 881 883
1087 1091 1093 1297 1301 1303 1423 1427 1429 1447 1451 1453 1483 1487 1489
1663 1667 1669 1693 1697 1699 1783 1787 1789 1867 1871 1873 1873 1877 1879
1993 1997 1999 2083 2087 2089 2137 2141 2143 2377 2381 2383 2683 2687 2689
2707 2711 2713 2797 2801 2803 3163 3167 3169 3253 3257 3259 3457 3461 3463
3463 3467 3469 3847 3851 3853 4153 4157 4159 4513 4517 4519 4783 4787 4789
5227 5231 5233 5413 5417 5419 5437 5441 5443 5647 5651 5653 5653 5657 5659
5737 5741 5743
46 prime triplets found below 6000.
</pre>
772

edits