Anonymous user
Vampire number: Difference between revisions
m
→{{header|REXX}}: added more comments, optimized the function.
(→{{header|REXX}}: added/changed comments and whitespace, aligned the output, optimized the program and function.) |
m (→{{header|REXX}}: added more comments, optimized the function.) |
||
Line 2,946:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
vampire: procedure;
if L//2 then return ''
do k=1 for L;
end /*k*/
w= L % 2 /*%: is REXX's integer ÷ */
Line 2,955:
top= left( reverse(bot), w)
bot= left(bot, w) /*determine limits of search*/
inc=
beg= max(bot, 10**(w-1) ) /*calculate where to start.*/
if inc==2 then if beg//2==0 then beg= beg + 1 /*possibly adjust the start.*/
/* [↑] odd BEG if odd INC*/
do d=beg to min(top, 10**w - 1) by inc /*use smart start, end, inc.*/
if
q=
if q*d//9 \== (q+d)//9 then iterate /*modulo 9 congruence test. */
if length(q) \==w then iterate /*Len of Q
if _==0 then if right(d, 1) ==0 then iterate
dq= d || q
t=
if p==0 then iterate d; t= delstr(t, p, 1)
end /*i*/
|