Anonymous user
Digital root/Multiplicative digital root: Difference between revisions
Digital root/Multiplicative digital root (view source)
Revision as of 13:14, 15 September 2017
, 6 years ago→idomatic version: added/changed comments and whitespace, optimized a function, used a template for the output.
No edit summary |
m (→idomatic version: added/changed comments and whitespace, optimized a function, used a template for the output.) |
||
Line 2,161:
=={{header|REXX}}==
===idomatic version===
<lang rexx>/*REXX
numeric digits 100 /*increase the number of
parse arg x /*
if x='' | x="," then x=123321 7739 893 899998 /*
say center('number', 8) ' persistence multiplicative digital root'
say copies('─' , 8) ' ─────────── ───────────────────────────'
/* [↑] the title and separator. */
do j=1 for words(x); n=word(x, j) /*process each number in the X list.*/
parse value
say right(n,8) center(mp,13) center(mdr,30)
end /*j*/ /* [↑] show MP
say; target=5
say 'MDR first ' target " numbers that have a matching MDR"
say '═══ ═══════════════════════════════════════════════════'
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
MDR: procedure; parse
y=r
'''output''' when using the default inputs:▼
end /*p*/ /* [↑] wash, rinse, and repeat ··· */
return p r /*return the persistence and the MDR. */</lang>
<pre>
number persistence multiplicative digital root
|