Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/Arithmetic-numbers/True-BASIC/arithmetic-numbers.basic
Normal file
41
Task/Arithmetic-numbers/True-BASIC/arithmetic-numbers.basic
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
LET n = 1
|
||||
DO
|
||||
LET div = 1
|
||||
LET divcnt = 0
|
||||
LET sum = 0
|
||||
DO
|
||||
LET quot = n/div
|
||||
IF quot < div THEN EXIT DO
|
||||
IF REMAINDER(n, div) = 0 THEN
|
||||
IF quot = div THEN !n is a square
|
||||
LET sum = sum+quot
|
||||
LET divcnt = divcnt+1
|
||||
EXIT DO
|
||||
ELSE
|
||||
LET sum = sum+div+quot
|
||||
LET divcnt = divcnt+2
|
||||
END IF
|
||||
END IF
|
||||
LET div = div+1
|
||||
LOOP
|
||||
|
||||
IF REMAINDER(sum, divcnt) = 0 THEN !n is arithmetic
|
||||
LET arithcnt = arithcnt+1
|
||||
IF arithcnt <= 100 THEN
|
||||
PRINT USING "####": n;
|
||||
IF REMAINDER(arithcnt, 20) = 0 THEN PRINT
|
||||
END IF
|
||||
IF divcnt > 2 THEN LET compcnt = compcnt+1
|
||||
SELECT CASE arithcnt
|
||||
CASE 1000
|
||||
PRINT
|
||||
PRINT USING "The #######th arithmetic number is #####,### up to which ###,### are composite.": arithcnt, n, compcnt
|
||||
CASE 10000, 100000, 1000000
|
||||
PRINT USING "The #######th arithmetic number is #####,### up to which ###,### are composite.": arithcnt, n, compcnt
|
||||
CASE ELSE
|
||||
REM
|
||||
END SELECT
|
||||
END IF
|
||||
LET n = n+1
|
||||
LOOP UNTIL arithcnt >= 1000000
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue