Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Perfect-numbers/FutureBasic/perfect-numbers.basic
Normal file
24
Task/Perfect-numbers/FutureBasic/perfect-numbers.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
_maxNum = 10000
|
||||
|
||||
local fn IsPerfectNumber( n as long ) as BOOL
|
||||
—————————————————————————————————————————————
|
||||
if ( n < 2 ) then exit fn = NO
|
||||
if ( n mod 2 == 1 ) then exit fn = NO
|
||||
long sum = 1, q, i
|
||||
for i = 2 to sqr(n)
|
||||
if ( n mod i == 0 )
|
||||
sum += i
|
||||
q = n / i
|
||||
if ( q > i ) then sum += q
|
||||
end if
|
||||
next
|
||||
end fn = ( n == sum )
|
||||
|
||||
printf @"Perfect numbers in range %ld..%ld",2,_maxNum
|
||||
|
||||
long i
|
||||
for i = 2 To _maxNum
|
||||
if ( fn IsPerfectNumber(i) ) then print i
|
||||
next
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue