Piprimes: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
Line 15: Line 15:
{{trans|Nim}}
{{trans|Nim}}


<lang 11l>F is_prime(n)
<syntaxhighlight lang="11l">F is_prime(n)
I n == 2
I n == 2
R 1B
R 1B
Line 34: Line 34:
I pi == 22
I pi == 22
L.break
L.break
print()</lang>
print()</syntaxhighlight>


{{out}}
{{out}}
Line 50: Line 50:
=={{header|Action!}}==
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>INCLUDE "H6:SIEVE.ACT"
<syntaxhighlight lang="action!">INCLUDE "H6:SIEVE.ACT"


PROC Main()
PROC Main()
Line 67: Line 67:
FI
FI
OD
OD
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Piprimes.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Piprimes.png Screenshot from Atari 8-bit computer]
Line 77: Line 77:
=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # Show some values of pi(n) - the number of priems <= n #
<syntaxhighlight lang="algol68">BEGIN # Show some values of pi(n) - the number of priems <= n #
# show pi(n) for n up to 21 #
# show pi(n) for n up to 21 #
INT max prime = 100; # guess of how large the primes we need are #
INT max prime = 100; # guess of how large the primes we need are #
Line 91: Line 91:
IF i MOD 10 = 0 THEN print( ( newline ) ) FI
IF i MOD 10 = 0 THEN print( ( newline ) ) FI
OD
OD
END</lang>
END</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 106: Line 106:
=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>primes: select 2..1000 => prime?
<syntaxhighlight lang="rebol">primes: select 2..1000 => prime?
piprimes: function [n] -> size select primes 'z [z =< n]
piprimes: function [n] -> size select primes 'z [z =< n]


loop split.every: 10 select map 1..100 => piprimes => [& < 22] 'a ->
loop split.every: 10 select map 1..100 => piprimes => [& < 22] 'a ->
print map a => [pad to :string & 3]</lang>
print map a => [pad to :string & 3]</syntaxhighlight>


{{out}}
{{out}}
Line 124: Line 124:


=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f PIPRIMES.AWK
# syntax: GAWK -f PIPRIMES.AWK
# converted from FreeBASIC
# converted from FreeBASIC
Line 151: Line 151:
return(1)
return(1)
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 168: Line 168:
==={{header|BASIC256}}===
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
{{trans|FreeBASIC}}
<lang BASIC256>function isPrime(v)
<syntaxhighlight lang="basic256">function isPrime(v)
if v < 2 then return False
if v < 2 then return False
if v mod 2 = 0 then return v = 2
if v mod 2 = 0 then return v = 2
Line 186: Line 186:
print running; " ";
print running; " ";
end while
end while
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 193: Line 193:


==={{header|FreeBASIC}}===
==={{header|FreeBASIC}}===
<lang freebasic>#define UPTO 22
<syntaxhighlight lang="freebasic">#define UPTO 22
#include "isprime.bas"
#include "isprime.bas"


Line 204: Line 204:
loop
loop
print : end
print : end
</syntaxhighlight>
</lang>
{{out}}<pre>
{{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>
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>


==={{header|Tiny BASIC}}===
==={{header|Tiny BASIC}}===
<lang tinybasic> LET N = 0
<syntaxhighlight lang="tinybasic"> LET N = 0
LET P = 0
LET P = 0
10 IF N = 22 THEN END
10 IF N = 22 THEN END
Line 224: Line 224:
LET I = I + 1
LET I = I + 1
IF I*I <= P THEN GOTO 110
IF I*I <= P THEN GOTO 110
RETURN</lang>
RETURN</syntaxhighlight>


==={{header|Yabasic}}===
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
{{trans|FreeBASIC}}
<lang yabasic>sub isPrime(v)
<syntaxhighlight lang="yabasic">sub isPrime(v)
if v < 2 then return False : fi
if v < 2 then return False : fi
if mod(v, 2) = 0 then return v = 2 : fi
if mod(v, 2) = 0 then return v = 2 : fi
Line 246: Line 246:
print running using "##", " ";
print running using "##", " ";
loop
loop
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 254: Line 254:


=={{header|C}}==
=={{header|C}}==
<lang c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>


Line 274: Line 274:
}
}
return 0;
return 0;
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 281: Line 281:


=={{header|Cowgol}}==
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
<syntaxhighlight lang="cowgol">include "cowgol.coh";


sub isPrime(n: uint8): (r: uint8) is
sub isPrime(n: uint8): (r: uint8) is
Line 311: Line 311:
end loop;
end loop;
print_nl();
print_nl();
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 326: Line 326:
=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)]
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)]
<lang fsharp>
<syntaxhighlight lang="fsharp">
// PiPrimes: Nigel Galloway. April 5th., 2021
// PiPrimes: Nigel Galloway. April 5th., 2021
let fN=let i=primes32() in Seq.unfold(fun(n,g,l)->Some(l,if n=g then (n+1,Seq.head i,l+1) else (n+1,g,l)))(1,Seq.head i,0)
let fN=let i=primes32() in Seq.unfold(fun(n,g,l)->Some(l,if n=g then (n+1,Seq.head i,l+1) else (n+1,g,l)))(1,Seq.head i,0)
fN|>Seq.takeWhile((>)22)|>Seq.chunkBySize 20|>Seq.iter(fun n->Array.iter(printf "%2d ") n; printfn "")
fN|>Seq.takeWhile((>)22)|>Seq.chunkBySize 20|>Seq.iter(fun n->Array.iter(printf "%2d ") n; printfn "")
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 341: Line 341:
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: formatting grouping io lists math.primes
<syntaxhighlight lang="factor">USING: formatting grouping io lists math.primes
math.primes.lists math.ranges math.statistics sequences ;
math.primes.lists math.ranges math.statistics sequences ;


21 lprimes lnth [1,b) [ prime? ] cum-count
21 lprimes lnth [1,b) [ prime? ] cum-count
10 group [ [ "%2d " printf ] each nl ] each</lang>
10 group [ [ "%2d " printf ] each nl ] each</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 359: Line 359:


=={{header|Fermat}}==
=={{header|Fermat}}==
<lang fermat>n:=0; p:=0
<syntaxhighlight lang="fermat">n:=0; p:=0
while n<22 do !n;!' ';p:=p+1;if Isprime(p)=1 then n:=n+1; fi; od</lang>
while n<22 do !n;!' ';p:=p+1;if Isprime(p)=1 then n:=n+1; fi; od</syntaxhighlight>
{{out}}<pre>
{{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>
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>


=={{header|FOCAL}}==
=={{header|FOCAL}}==
<lang FOCAL>01.10 S C=0
<syntaxhighlight lang="focal">01.10 S C=0
01.20 S N=1
01.20 S N=1
01.30 T %3,C
01.30 T %3,C
Line 378: Line 378:
02.30 I (I*I-N-1)2.4;S A=1;R
02.30 I (I*I-N-1)2.4;S A=1;R
02.40 S A=N/I
02.40 S A=N/I
02.50 I (FITR(A)-A)2.2;S A=0</lang>
02.50 I (FITR(A)-A)2.2;S A=0</syntaxhighlight>
{{out}}
{{out}}
<pre>= 0= 1= 2= 2= 3= 3= 4= 4= 4= 4= 5= 5= 6= 6= 6= 6
<pre>= 0= 1= 2= 2= 3= 3= 4= 4= 4= 4= 5= 5= 6= 6= 6= 6
Line 387: Line 387:


=={{header|J}}==
=={{header|J}}==
<lang J>}.@(>:@i.&.p:) 21</lang>
<syntaxhighlight lang="j">}.@(>:@i.&.p:) 21</syntaxhighlight>
{{out}}
{{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>
<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>
Line 394: Line 394:
{{trans|Wren}}
{{trans|Wren}}
{{libheader|Go-rcu}}
{{libheader|Go-rcu}}
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 426: Line 426:
}
}
fmt.Printf("\n\nHighest n for this range = %d.\n", len(pi))
fmt.Printf("\n\nHighest n for this range = %d.\n", len(pi))
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 454: Line 454:


'''Preliminaries'''
'''Preliminaries'''
<lang jq>def count(s): reduce s as $x (null; .+1);
<syntaxhighlight lang="jq">def count(s): reduce s as $x (null; .+1);


def emit_until(cond; stream):
def emit_until(cond; stream):
Line 462: Line 462:
if . == 2 then 3
if . == 2 then 3
else first(range(.+2; infinite; 2) | select(is_prime))
else first(range(.+2; infinite; 2) | select(is_prime))
end;</lang>
end;</syntaxhighlight>
'''The task'''
'''The task'''
<lang jq># Generate pi($n) for $n > 0
<syntaxhighlight lang="jq"># Generate pi($n) for $n > 0
def pi_primes:
def pi_primes:
foreach range(1; infinite) as $i ({n:0, np: 2}; # n counts, np is the next prime
foreach range(1; infinite) as $i ({n:0, np: 2}; # n counts, np is the next prime
Line 473: Line 473:
.n);
.n);


emit_until(. >= 22; pi_primes)</lang>
emit_until(. >= 22; pi_primes)</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 502: Line 502:


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>using Primes
<syntaxhighlight lang="julia">using Primes


function listpiprimes(maxpi)
function listpiprimes(maxpi)
Line 514: Line 514:


listpiprimes(22)
listpiprimes(22)
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
0 1 2 2 3 3 4 4 4 4
0 1 2 2 3 3 4 4 4 4
Line 527: Line 527:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>pi = PrimePi /@ Range[Prime[22] - 1];
<syntaxhighlight lang="mathematica">pi = PrimePi /@ Range[Prime[22] - 1];
Multicolumn[pi, {Automatic, 10}, Appearance -> "Horizontal"]</lang>
Multicolumn[pi, {Automatic, 10}, Appearance -> "Horizontal"]</syntaxhighlight>
{{out}}
{{out}}
<pre>0 1 2 2 3 3 4 4 4 4
<pre>0 1 2 2 3 3 4 4 4 4
Line 540: Line 540:


=={{header|Nim}}==
=={{header|Nim}}==
<lang Nim>import strutils
<syntaxhighlight lang="nim">import strutils


func isPrime(n: Natural): bool =
func isPrime(n: Natural): bool =
Line 562: Line 562:
inc pi
inc pi
if pi == 22: break
if pi == 22: break
echo()</lang>
echo()</syntaxhighlight>




Line 576: Line 576:


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<lang parigp>n = 1;
<syntaxhighlight lang="parigp">n = 1;
while( primepi( n ) < 22,
while( primepi( n ) < 22,
printf( "%3d", primepi(n) );
printf( "%3d", primepi(n) );
if( n++ % 10 == 1,
if( n++ % 10 == 1,
print()) )</lang>
print()) )</syntaxhighlight>
{{out}}
{{out}}
0 1 2 2 3 3 4 4 4 4
0 1 2 2 3 3 4 4 4 4
Line 593: Line 593:
=={{header|Perl}}==
=={{header|Perl}}==
{{libheader|ntheory}}
{{libheader|ntheory}}
<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;
use feature 'state';
use feature 'state';
Line 599: Line 599:


my @pi = map { state $pi = 0; $pi += is_prime $_ ? 1 : 0 } 1..1e4;
my @pi = map { state $pi = 0; $pi += is_prime $_ ? 1 : 0 } 1..1e4;
do { print shift(@pi) . ' ' } until $pi[0] >= 22;</lang>
do { print shift(@pi) . ' ' } until $pi[0] >= 22;</syntaxhighlight>
{{out}}
{{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>
<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>


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">ix</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">ix</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
Line 618: Line 618:
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"pi[1..%d]:\n%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"pi[1..%d]:\n%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)})</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 636: Line 636:
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].


<lang Quackery> [ 0 swap
<syntaxhighlight lang="quackery"> [ 0 swap
1 - times
1 - times
[ i 1+ isprime + ] ] is pi ( n --> n )
[ i 1+ isprime + ] ] is pi ( n --> n )
Line 642: Line 642:
2 [ dup pi dup 22 < while
2 [ dup pi dup 22 < while
echo sp 1+ again ]
echo sp 1+ again ]
2drop</lang>
2drop</syntaxhighlight>


{{out}}
{{out}}
Line 649: Line 649:


=={{header|Raku}}==
=={{header|Raku}}==
<lang perl6>my @pi = (1..*).map: { state $pi = 0; $pi += .is-prime };
<syntaxhighlight lang="raku" line>my @pi = (1..*).map: { state $pi = 0; $pi += .is-prime };


say @pi[^(@pi.first: * >= 22, :k)].batch(10)».fmt('%2d').join: "\n";</lang>
say @pi[^(@pi.first: * >= 22, :k)].batch(10)».fmt('%2d').join: "\n";</syntaxhighlight>
{{out}}
{{out}}
<pre> 0 1 2 2 3 3 4 4 4 4
<pre> 0 1 2 2 3 3 4 4 4 4
Line 663: Line 663:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program finds and displays pi(n) for 0 < N ≤ prime(22) {the 22nd prime is 87},*/
<syntaxhighlight lang="rexx">/*REXX program finds and displays pi(n) for 0 < N ≤ prime(22) {the 22nd prime is 87},*/
/*────────────────────────── where the pi function returns the number of primes ≤ N.*/
/*────────────────────────── where the pi function returns the number of primes ≤ N.*/
parse arg hi cols . /*obtain optional argument from the CL.*/
parse arg hi cols . /*obtain optional argument from the CL.*/
Line 707: Line 707:
end /*k*/ /* [↑] only process numbers ≤ √ J */
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j; s.#= j*j; !.j= 1 /*bump # of Ps; assign next P; P²; P# */
#= #+1; @.#= j; s.#= j*j; !.j= 1 /*bump # of Ps; assign next P; P²; P# */
end /*j*/; return</lang>
end /*j*/; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>
Line 726: Line 726:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
load "stdlib.ring"
load "stdlib.ring"


Line 759: Line 759:
see nl + "Found " + row + " Piprimes." + nl
see nl + "Found " + row + " Piprimes." + nl
see "done..." + nl
see "done..." + nl
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 777: Line 777:


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>1..(prime(22)-1) -> map { .prime_count }.say</lang>
<syntaxhighlight lang="ruby">1..(prime(22)-1) -> map { .prime_count }.say</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 787: Line 787:
{{libheader|Wren-seq}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/math" for Int
<syntaxhighlight lang="ecmascript">import "/math" for Int
import "/seq" for Lst
import "/seq" for Lst
import "/fmt" for Fmt
import "/fmt" for Fmt
Line 807: Line 807:
System.print("pi(n), the number of primes <= n, where n >= 1 and pi(n) < 22:")
System.print("pi(n), the number of primes <= n, where n >= 1 and pi(n) < 22:")
for (chunk in Lst.chunks(pi, 10)) Fmt.print("$2d", chunk)
for (chunk in Lst.chunks(pi, 10)) Fmt.print("$2d", chunk)
System.print("\nHighest n for this range = %(pi.count).")</lang>
System.print("\nHighest n for this range = %(pi.count).")</syntaxhighlight>


{{out}}
{{out}}
Line 825: Line 825:


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is a prime number
<syntaxhighlight lang="xpl0">func IsPrime(N); \Return 'true' if N is a prime number
int N, I;
int N, I;
[if N <= 1 then return false;
[if N <= 1 then return false;
Line 842: Line 842:
if IsPrime(P) then N:= N+1;
if IsPrime(P) then N:= N+1;
until N >= 22;
until N >= 22;
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}