10 REM PERFECT NUMBERS 20 *TV 255,0 30 MODE4 40 VDU 19,0,4,0,0,0 50 CLS 60 PRINT"This program searches for perfect numbers on the assumption that they follow the same mathematical expression as the highest known perfect number." 70 PRINT:PRINT"Whenever a perfect number is found it is printed on screen and to the printer before continuing the search for the next number." 80 PRINT:PRINT"Be warned that the fifth perfect number will take quite some time to find. Probably longer than 10 days !!":PRINT 90 PRINT"Please prepare your printer..." 100 PRINT:PRINT"...then press any key to continue." 110 X=GET 120 CLS 130 PRINT:PRINT TAB(25,1) "COUNTER" 140 J=0 150 FOR N=1 TO 500 160 IF J=20 THEN GOTO 300 170 A%=(2^J)*((2^(J+1))-1) 180 J=J+1 190 X%=1 200 M%=1 210 M%=M%+1 220 PRINT TAB(20,3) M% 230 IF M%>A%/2+1 THEN GOTO 290 240 IF X%>A% THEN GOTO 290 250 B=A%/M% 260 IF B=INT(B) THEN X%=X%+B ELSE GOTO 210 270 IF B=2 THEN PRINT TAB(20,3) A% ELSE GOTO 210 280 IF X%=A% THEN PROCperfect 290 NEXT 300 END 310 DEF PROCperfect 320 Z=Z+1 330 VDU2:IF Z=1 PRINT TAB(0,5+Z)"I'M A PERFECT NUMBER ...",A%:VDU3 340 VDU2:IF Z=2 PRINT TAB(0,5+Z)"...AND SO AM I ...",A%:PRINT:VDU3 350 VDU2:IF Z=2 PRINT TAB(0,7+Z)"PLEASE WAIT.ANOTHER WILL BE ALONG SOON.":PRINT:VDU3 360 VDU2:IF Z=3 PRINT TAB(0,8+Z)"HERE I AM ...",A%:PRINT:VDU3 370 IF Z=3 THEN PROCtexta 380 IF Z=4 THEN PROCtextb 390 VDU2:IF Z>4 THEN PRINT "WAS IT WORTH THE WAIT ...",A%:VDU3 400 VDU3 410 ENDPROC 420 DEF PROCtexta 430 VDU2:PRINT TAB(0,10+Z)"THERE'S NOT MANY OF US AROUND YOU KNOW." 440 PRINT "YOU'LL NOW HAVE A SLIGHT WAIT BEFORE YOU SEE ANOTHER ONE(COUNTER=4100 approx).":PRINT:VDU3 450 ENDPROC 460 DEF PROCtextb 470 VDU2:PRINT TAB(0,12+Z)"NOT TOO LONG A WAIT I HOPE ...",A%:PRINT 480 PRINT "YOU'LL NOW HAVE A MUCH LONGER WAIT." 490 PRINT "BE PREPARED TO LEAVE YOUR COMPUTER ON ALL WEEK OR POSSIBLY EVEN LONGER!":PRINT 500 PRINT "THE NEXT PERFECT NUMBER IS MUCH LARGER!!" 510 ENDPROC