Piprimes: Difference between revisions

Added XPL0 example.
(Added Go)
(Added XPL0 example.)
Line 608:
 
Highest n for this range = 78.
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is a prime number
int N, I;
[if N <= 1 then return false;
for I:= 2 to sqrt(N) do
if rem(N/I) = 0 then return false;
return true;
];
 
int Count, N, P;
[Count:= 0; N:= 0; P:= 1;
repeat if N<10 then ChOut(0, ^ );
IntOut(0, N);
Count:= Count+1;
if rem(Count/20) then ChOut(0, ^ ) else CrLf(0);
P:= P+1;
if IsPrime(P) then N:= N+1;
until N >= 22;
]</lang>
 
{{out}}
<pre>
0 1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 7 7 8 8
8 8 9 9 9 9 9 9 10 10 11 11 11 11 11 11 12 12 12 12
13 13 14 14 14 14 15 15 15 15 15 15 16 16 16 16 16 16 17 17
18 18 18 18 18 18 19 19 19 19 20 20 21 21 21 21 21 21
</pre>
772

edits