Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
44
Task/Arithmetic-numbers/ANSI-BASIC/arithmetic-numbers.basic
Normal file
44
Task/Arithmetic-numbers/ANSI-BASIC/arithmetic-numbers.basic
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
100 REM Arithmetic numbers
|
||||
110 LET N = 1
|
||||
120 LET ArithmCnt = 0
|
||||
130 LET CompCnt = 0
|
||||
140 PRINT "The first 100 arithmetic numbers are:";
|
||||
150 PRINT
|
||||
160 DO
|
||||
170 LET Dv = 1
|
||||
180 LET DvCnt = 0
|
||||
190 LET Sum = 0
|
||||
200 DO
|
||||
210 LET Quot = INT(N / Dv)
|
||||
220 IF Quot < Dv THEN EXIT DO
|
||||
230 IF (Quot = Dv) AND (MOD(N, Dv) = 0) THEN
|
||||
240 REM N is a square
|
||||
250 LET Sum = Sum + Quot
|
||||
260 LET DvCnt = DvCnt + 1
|
||||
270 EXIT DO
|
||||
280 END IF
|
||||
290 IF MOD(N, Dv) = 0 THEN
|
||||
300 LET Sum = Sum + Dv + Quot
|
||||
310 LET DvCnt = DvCnt + 2
|
||||
320 END IF
|
||||
330 LET Dv = Dv + 1
|
||||
340 LOOP
|
||||
350 IF MOD(Sum, DvCnt) = 0 THEN
|
||||
360 REM N is arithmetic
|
||||
370 LET ArithmCnt = ArithmCnt + 1
|
||||
380 IF ArithmCnt <= 100 THEN
|
||||
390 PRINT USING "####": N;
|
||||
400 IF MOD(ArithmCnt, 10) = 0 THEN PRINT
|
||||
410 END IF
|
||||
420 IF DvCnt > 2 THEN LET CompCnt = CompCnt + 1
|
||||
430 IF (ArithmCnt = 1000) OR (ArithmCnt = 10000) THEN
|
||||
440 PRINT
|
||||
450 PRINT USING "The #####th arithmetic number is ##### ": ArithmCnt, N;
|
||||
460 PRINT USING "up to which ##### ": CompCnt;
|
||||
470 PRINT "are composite.";
|
||||
480 END IF
|
||||
490 END IF
|
||||
500 LET N = N + 1
|
||||
510 LOOP UNTIL ArithmCnt > 10001
|
||||
520 PRINT
|
||||
530 END
|
||||
Loading…
Add table
Add a link
Reference in a new issue