Arithmetic numbers: Difference between revisions

Line 763:
 
for N = 1 to 2000000)
 
Div = 1 : DivCnt = 0 : Sum = 0
 
while 1
 
Quot = N / Div
If Quot < Div Then Exit while
If Quot = Div And (N Mod Div) = 0 'N is a square
Sum += Quot
DivCnt += 1
Exit while
End If
If (N Mod Div) = 0
Sum += Div + Quot
DivCnt += 2
End If
Div ++
 
wend
 
 
 
If (Sum Mod DivCnt) = 0 'N is arithmetic
ArithCnt ++
 
If ArithCnt <= 100
Print Using "####"; N;
If (ArithCnt Mod 20) = 0 Then PRINT
End If
 
If DivCnt > 2 Then CompCnt ++
 
Select Case ArithCnt
Case 1e3
PRINT
PRINT USING "The #######th arithmetic number is";ArithCnt;
PRINT USING "#####,### up to which ";N;
PRINT USING "###,### are composite. ";compcnt
Case 1e4, 1e5, 1e6
PRINT USING "The #######th arithmetic number is";ArithCnt;
PRINT USING "#####,### up to which ";N;
PRINT USING "###,### are composite. ";compcnt
End Select
 
if ArithCnt = 1e6 then exit next
End If
 
 
next N
 
Line 818:
print
print "It took " + str$(TimeTaken) + " seconds to complete." // Approx 1.5 seconds on a M1 Mac Mini ( Macmini9,1 )
 
 
handleevents
44

edits