Duffinian numbers: Difference between revisions
Content added Content deleted
(Initial FutureBasic task solution added) |
|||
Line 694: | Line 694: | ||
next |
next |
||
end fn = isPrime |
end fn = isPrime |
||
local fn GCD( a as long, b as long ) as long |
local fn GCD( a as long, b as long ) as long |
||
Line 702: | Line 701: | ||
result = fn GCD( b mod a, a ) |
result = fn GCD( b mod a, a ) |
||
end fn = result |
end fn = result |
||
local fn SumDiv( num as NSUInteger ) as NSUInteger |
local fn SumDiv( num as NSUInteger ) as NSUInteger |
||
Line 718: | Line 716: | ||
result = sum + 1 |
result = sum + 1 |
||
end fn = result |
end fn = result |
||
local fn IsDuffinian( n as NSUInteger) as BOOL |
local fn IsDuffinian( n as NSUInteger) as BOOL |
||
BOOL result = NO |
BOOL result = NO |
||
if ( fn IsPrime(n) == NO and fn GCD( fn SumDiv(n), n ) == 1 ) |
if ( fn IsPrime(n) == NO and fn GCD( fn SumDiv(n), n ) == 1 ) then exit fn = YES |
||
result = YES |
|||
else |
|||
result = NO |
|||
end if |
|||
end fn = result |
end fn = result |
||
local fn FindDuffinians |
local fn FindDuffinians |
||
Line 757: | Line 749: | ||
CFTimeInterval t |
CFTimeInterval t |
||
t = fn CACurrentMediaTime |
t = fn CACurrentMediaTime |
||
fn FindDuffinians |
fn FindDuffinians |
||
Line 792: | Line 783: | ||
Compute time: 2963.753 ms |
Compute time: 2963.753 ms |
||
</pre> |
</pre> |
||
=={{header|Go}}== |
=={{header|Go}}== |