Data update
This commit is contained in:
parent
07c7092a52
commit
61b93a2cd1
313 changed files with 6160 additions and 346 deletions
29
Task/Amicable-pairs/FutureBasic/amicable-pairs.basic
Normal file
29
Task/Amicable-pairs/FutureBasic/amicable-pairs.basic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
local fn Sigma( n as long ) as long
|
||||
long i, root, sum = 1
|
||||
|
||||
if n == 1 then exit fn = 0
|
||||
root = sqr(n)
|
||||
for i = 2 to root
|
||||
if ( n mod i == 0 ) then sum += i + n/i
|
||||
next
|
||||
if root * root == n then sum -= root
|
||||
end fn = sum
|
||||
|
||||
void local fn CalculateAmicablePairs( limit as long )
|
||||
long i, m
|
||||
|
||||
printf @"\nAmicable pairs through %ld are:\n", limit
|
||||
for i = 2 to limit
|
||||
m = fn Sigma(i)
|
||||
if ( m > i )
|
||||
if ( fn Sigma(m) == i ) then printf @"%6ld and %ld", i, m
|
||||
end if
|
||||
next
|
||||
end fn
|
||||
|
||||
CFTimeInterval t
|
||||
t = fn CACurrentMediaTime
|
||||
fn CalculateAmicablePairs( 20000 )
|
||||
printf @"\nCompute time: %.3f ms",(fn CACurrentMediaTime-t)*1000
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue