Extensible prime generator: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: simplified some display code.) |
m (→{{header|REXX}}: added wording to the output text.) |
||
Line 4,968: | Line 4,968: | ||
parse arg f .; if f=='' then f= 20 /*allow specifying number for 1 ──► F.*/ |
parse arg f .; if f=='' then f= 20 /*allow specifying number for 1 ──► F.*/ |
||
_i= ' (inclusive) '; _b= 'between '; _tnp= 'the number of primes' _b; _tn= 'the primes' |
_i= ' (inclusive) '; _b= 'between '; _tnp= 'the number of primes' _b; _tn= 'the primes' |
||
call primes f; do j=1 for f; $= $ @.j; end /*j*/ |
call primes f; do j=1 for f; $= $ @.j; end /*j*/ |
||
say 'the first ' f " primes are: " $ |
|||
say |
|||
call primes -150; do j=100 to 150; if !.j==1 then $= $ j; end /*j*/ |
call primes -150; do j=100 to 150; if !.j==1 then $= $ j; end /*j*/ |
||
say _tn _b '100 to 150' _i "are: " $ |
|||
say |
|||
call primes -8000; do j=7700 to 8000; if !.j==1 then $= $ j; end /*j*/ |
call primes -8000; do j=7700 to 8000; if !.j==1 then $= $ j; end /*j*/ |
||
say _tnp '7,700 and 8,000' _i "is: " words($) |
|||
say |
|||
call primes 10000 |
call primes 10000 |
||
say 'the 10,000th prime is: ' @.10000 |
|||
exit 0 /*stick a fork in it, we're all done. */ |
exit 0 /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Line 5,017: | Line 5,017: | ||
{{out|output|text= when using the default input:}} |
{{out|output|text= when using the default input:}} |
||
<pre> |
<pre> |
||
first 20 primes are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 |
the first 20 primes are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 |
||
the primes between 100 to 150 (inclusive) are: 101 103 107 109 113 127 131 137 139 149 |
the primes between 100 to 150 (inclusive) are: 101 103 107 109 113 127 131 137 139 149 |
||
the number of primes between |
the number of primes between 7,700 and 8,000 (inclusive) is: 30 |
||
the |
the 10,000th prime is: 104729 |
||
</pre> |
</pre> |
||