50 lines
899 B
Text
50 lines
899 B
Text
multDigitalRoot=lambda (n as decimal) ->{
|
|
if n<0 then error "Negative numbers not allowed"
|
|
def decimal mdr, mp, nn
|
|
nn=n
|
|
do
|
|
mdr=IF(nn>0->1@, 0@)
|
|
while nn>0
|
|
mdr*=nn mod 10@
|
|
nn|div 10@
|
|
end while
|
|
mp++
|
|
nn=mdr
|
|
when mdr>=10
|
|
=(mdr, mp)
|
|
}
|
|
Document doc$
|
|
ia=(123321, 7739, 893, 899998)
|
|
in_ia=each(ia)
|
|
while in_ia
|
|
(mdr, mp)=multDigitalRoot(array(in_ia))
|
|
doc$=format$("{0::-9} mdr = {1} MP = {2}", array(in_ia), mdr, mp)+{
|
|
}
|
|
end while
|
|
let n=0@, count=0&
|
|
dim ia2(0 to 9, 0 to 5)
|
|
do
|
|
mdr=multDigitalRoot(n)#val(0)
|
|
if ia2(mdr, 0)<5 then
|
|
ia2(mdr, 0)++
|
|
ia2(mdr, ia2(mdr, 0))=n
|
|
count++
|
|
end if
|
|
n++
|
|
when count<50
|
|
|
|
doc$={MDR n0 n1 n2 n3 n4
|
|
}
|
|
doc$={=== ============================
|
|
}
|
|
for i=0 to 9
|
|
doc$=format$("{0}: ", i)
|
|
for j=1 to 5
|
|
doc$=format$("{0::-6}", ia2(i, j))
|
|
next
|
|
doc$={
|
|
}
|
|
next
|
|
Clipboard doc$
|
|
// Print like in a file (-2 is for console):
|
|
Print #-2, doc$
|