Anonymous user
Unprimeable numbers: Difference between revisions
→{{header|REXX}}: simplified parts of the program, optimized for speed.
(→{{header|Wren}}: Now uses Wren-math module.) |
(→{{header|REXX}}: simplified parts of the program, optimized for speed.) |
||
Line 1,775:
if !.new then iterate j /*This new number a prime? " " */
end /*e_*/
/* [↑] examine a new 1st digit of J. */
do f_=0 for 10; new= (f_||meat) + 0 /*obtain a different number (than J).*/
Line 1,794 ⟶ 1,792:
if #<=n then $$= $$ commas(j) /*maybe add unprimeable # to $$ list.*/
if #==x then $.ox= commas(j) /*assign the Xth unprimeable number.*/
if $._==. then $._= j /*the 1st unprimeable # that ends in _.*/
if $.3==. then iterate; if $.7==. then iterate /*test if specific #'s found.*/
Line 1,814 ⟶ 1,812:
th:procedure;parse arg x;return x||word('th st nd rd',1+(x//10)*(x//100%10\==1)*(x//10<4))
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: @.1=2;
!.=0;
do lim=100 until lim*lim>=hp
parse var j '' -1 _;if _==5 then iterate /*
if j//
if j// 7==0 then iterate /* " " " " 7? " " " */
if j//11==0 then iterate /* " " " " 11? " " " */
if j//13==0 then iterate /*
if j//17==0
if j//19==0 then iterate /* " " " " 19? " " " */
if j//23==0 then iterate /* " " " " 23? " " " */
if j//29==0 then iterate /* " " " " 29? " " " */
do k=11 while k*k<=j /*divide by some generated odd primes. */
if j // @.k==0 then iterate j /*Is J divisible by P? Then not prime*/
end /*k*/ /* [↓] a prime (J) has been found. */
end /*j*/;
{{out|output|text= when using the default inputs:}}
|