Munchausen numbers: Difference between revisions

m
→‎version 3: changed whitespace.
m (→‎version 2: added whitespace.)
m (→‎version 3: changed whitespace.)
Line 1,899:
It is about   '''3'''   times faster than REXX version 1.
<lang rexx>/*REXX program finds and displays Münchhausen numbers from one to a specified number (Z)*/
@.= 0; do i=1 for 9; @.i= i**i; end /*precompute powers for non-zero digits*/
parse arg z . /*obtain optional argument from the CL.*/
if z=='' | z=="," then z=5000 5000 /*Not specified? Then use the default.*/
@is='is a Münchhausen number.'; do j=1 for z /* [↓] traipse through all the numbers*/
if isMunch(j) then say right(j, 11) @is
Line 1,910:
if $>ox then return 0 /*is sum too large?*/
do while x\=='' & $<=ox /*any more digits ?*/
parse var x _ +1 x; $= $ + @._ /*sum 6th & up digs*/
end /*while*/
return $==ox /*it is or it ain't*/</lang>