Weird numbers: Difference between revisions

m
→‎optimized version: elided a test that is only good for smallish weird numbers.
m (→‎vanilla version: fixed a truncated statement.)
m (→‎optimized version: elided a test that is only good for smallish weird numbers.)
Line 2,119:
if cols>0 then say ' index │'center(' weird numbers', 1 + cols*(w+1) )
if cols>0 then say '───────┼'center("" , 1 + cols*(w+1), '─')
@@.= 1; @@.0= 0; @@.2=0 /*semaphores for last decimal digit. */
weirds= 0; !!.= 0 /*the count of weird numbers (so far).*/
idx= 1; $= /*index for the output list; $: 1 line*/
Line 2,172 ⟶ 2,171:
end /*j*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
weird: procedure expose !!. @@. sigma; parse arg x /*obtain a # to be tested /*procedure to determinefor weirdness of X*/
parse arg x '' -1 _ /*obtain a # to be tested for weirdness*/
if x<70 | x//3==0 then return 0 /*test if X is too low or multiple of 3*/
if x>9e2 then if @@._ then return 0 /*Is an acceptable last decimal digit? */
if !!.x then return 1 /*Is this a prime*previous #? Found one*/
parse value DaS(x) with sigma divs /*obtain sigma and the proper divisors.*/