Anonymous user
Digital root/Multiplicative digital root: Difference between revisions
Digital root/Multiplicative digital root (view source)
Revision as of 22:49, 3 May 2014
, 10 years ago→{{header|REXX}}: re-did the output.
m (→{{header|REXX}}: modified the MDR subroutine to accept negative numbers as well.) |
m (→{{header|REXX}}: re-did the output.) |
||
Line 584:
say '═══ ' copies("═",10+(target+2)**2%2)
do m=0 until hits==target /*find five #'s with an MDR of K.*/
?=right(m,1) /*obtain right-most digit of M. */
if k\==0 then if ?==0 then iterate
select
when k==3 | k==5 | k==7 | k==9 then nop
when k==3 then if ?\==1 & ?\==3 then iterate
when k==5 then if ?//2==0 then iterate
when k==7 then if ?\==1 & ?\==7 then iterate
when k==9 then if ?\==1 & ?\==3 & ?\==9 then iterate
otherwise if word(mdr(m),2)\==k then iterate▼
end /*select*/
if k==1 then m=copies(1,hits+1)
hits=hits+1; _=space(_ m',') /*yes, we got a hit, add to list.*/
end /*m*/ /* [↑] built a list of MDRs = k */
Line 623 ⟶ 624:
1: [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111, 11111111111, 111111111111, 1111111111111, 11111111111111, 111111111111111, 1111111111111111, 11111111111111111, 111111111111111111, 1111111111111111111, 11111111111111111111]
2: [2, 12, 21, 26, 34, 37, 43, 62, 73, 112, 121, 126, 134, 137, 143, 162, 173, 211, 216, 223]
3: [
4: [4, 14, 22, 27, 39, 41, 72, 89, 93, 98, 114, 122, 127, 139, 141, 172, 189, 193, 198, 212]
5: [
6: [6, 16, 23, 28, 32, 44, 47, 48, 61, 68, 74, 82, 84, 86, 116, 123, 128, 132, 144, 147]
7: [
8: [8, 18, 24, 29, 36, 38, 42, 46, 49, 63, 64, 66, 67, 76, 77, 79, 81, 83, 88, 92]
9: [
</pre>
|