17 lines
386 B
Plaintext
17 lines
386 B
Plaintext
100 sub isperfect(n)
|
|
110 if (n < 2) or (n mod 2 = 1) then isperfect = false
|
|
120 sum = 1
|
|
130 for i = 2 to sqr(n)
|
|
140 if n mod i = 0 then
|
|
150 sum = sum+i
|
|
160 q = int(n/i)
|
|
170 if q > i then sum = sum+q
|
|
180 endif
|
|
190 next
|
|
200 isperfect = n = sum
|
|
210 end sub
|
|
220 print "The first 4 perfect numbers are:"
|
|
230 for i = 2 to 10000
|
|
240 if isperfect(i) then print i;" ";
|
|
250 next i
|