8-Bit Software Online Conversion

Perfect Numbers Example 1 - Listing

10 REM PGM. NAME: PERFT2. Tests a num ber to see if it is perfect. 20 MODE7 30 INPUT"Enter an even number. "N$ 40 N%=VAL(N$):IF INT(N%/2)<>N%/2 THEN N%=N%+1 50 PRINT'"Factor";TAB(10)"Total of fa ctors"' 60 D%=0:T%=0 70 REPEAT 80 D%=D%+1 90 IF N%/D%=INT(N%/D%) AND D%<>SQR(N% ) AND D%<>1 THEN T%=T%+D%:PRINT TAB(0)D% ,TAB(20)T%:T%=T%+N%/D%:PRINT TAB(0)N%/D% ,TAB(20)T% 95 IF N%/D%=INT(N%/D%) AND (D%=SQR(N% ) OR D%=1) THEN T%=T%+D%:PRINT TAB(0)D% ,TAB(20)T% 100 UNTIL D%>SQR(N%) 110 IF T%<N% THEN PRINT'"The number "; N%" is defective." ELSE IF T%=N% THEN PR INT'"The number ";N%;" is perfect." ELSE IF T%>N% THEN PRINT'"The number ";N%;" is excessive." 120 PRINT''"Press the SPACE-BAR to ent er another." 130 G=GET:GOTO 20