RosettaCodeData/Task/Arithmetic-numbers/M2000-Interpreter/arithmetic-numbers.m2000

25 lines
745 B
Plaintext

set fast !
profiler
form 80, 50
const msg$="The {0::-7}th arithmetic number is {1:-9} up to which {2:-7} are composite."
const f1$="#####,###"
const f2$="###,###"
print "The first 100 arithmetic numbers are:"
C=0&
D=0&: t=0&
mm=1000&
mm1=1000000&
n=1228663 ' 125587 ' 12953 ' 1361
dim L(2 to n)=1, M(2 to n)=1 : c++: Print 1,
for i=2 to n {for j=i to n step i {L(j)+=i:M(j)++}:if L(i) mod M(i) = 0& then {if M(i)>2 then D++
C++:if C<=100& then print i, else i++: goto exit1
}}
exit1:
refresh
for i=i to n {for j=i to n step i {L(j)+=i:M(j)++}:if L(i) mod M(i) = 0& then {if M(i)>2 then D++
C++:if C=mm then ? format$(msg$, c, str$(i,f1$), str$(d,f2$)):refresh:mm*=10&:if mm>mm1 then goto exit2
}}
exit2:
print
print round(timecount/1000, 1);"s"