Jump to content

Next special primes: Difference between revisions

Added XPL0 example.
m (syntax highlighting fixup automation)
(Added XPL0 example.)
Line 1,218:
}</syntaxhighlight>
 
{{out}}
<pre>
Special primes under 1,050:
Prime1 Prime2 Gap
2 3 1
3 5 2
5 11 6
11 19 8
19 29 10
29 41 12
41 59 18
59 79 20
79 101 22
101 127 26
127 157 30
157 191 34
191 227 36
227 269 42
269 313 44
313 359 46
359 409 50
409 461 52
461 521 60
521 587 66
587 659 72
659 733 74
733 809 76
809 887 78
887 967 80
967 1049 82
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">include xpllib; \for IsPrime and Print
 
int I, LastSpecial, LastGap;
[LastSpecial:= 3; LastGap:= 1;
Print("Special primes under 1,050:\n");
Print("Prime1 Prime2 Gap\n");
Print("%6d %6d %3d\n", 2, 3, LastGap);
for I:= 5 to 1050-1 do
[if IsPrime(I) and I-LastSpecial > LastGap then
[LastGap:= I - LastSpecial;
Print("%6d %6d %3d\n", LastSpecial, I, LastGap);
LastSpecial:= I;
];
I:= I+1;
];
]</syntaxhighlight>
{{out}}
<pre>
295

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.