Code: Select all

```
#! /usr/bin/rexx
Trace "O"
signal on novalue name novalue
numeric digits 32
parse arg n
if n = "" then ,
n = 100
w = length(n)
k = 1
say right(k, w) 2
do p = 3 by 2 while k < n
if isprime(p) then do
k += 1
say right(k, w) p
end
end
Exit
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
isPrime: procedure
parse arg p
if p = 1 then ,
return 0
if p < 4 then ,
return 1
if p // 2 = 0 then ,
return 0
if p < 9 then ,
return 1
if p // 3 = 0 then ,
return 0
f = 5
do while ( f * f <= p )
if p // f = 0 then ,
return 0
if p // (f+2) = 0 then ,
return 0
f +=6
end
return 1
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
logic_error:
say "**"copies(" -", 35)
say "**"
say "**" "Logic error at line '"sigl"' "
say "**"
say "**"copies(" -", 35)
exit
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
novalue:
say "**"copies(" -", 35)
say "**"
say "**" "Novalue trapped, line '"sigl"' var '"condition("D")"' "
say "**"
say "**"copies(" -", 35)
exit
```