18 lines
659 B
Text
18 lines
659 B
Text
include "NSLog.incl"
|
|
|
|
local fn SumOfProperDivisors( n as NSUInteger ) as NSUinteger
|
|
NSUinteger sum = 1
|
|
|
|
cln for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
|
|
end fn = sum
|
|
|
|
NSUinteger n, c
|
|
cln for (n = 1, c = 0; c < 25; n += 2 ) if ( n < SumOfProperDivisors( n ) ) NSLog( @"%2lu: %lu", ++c, n );
|
|
|
|
cln for ( ; c < 1000; n += 2 ) if ( n < SumOfProperDivisors( n ) ) c ++;
|
|
NSLog( @"\nThe one thousandth abundant odd number is: %lu\n", n )
|
|
|
|
cln for ( n = 1000000001 ;; n += 2 ) if ( n < SumOfProperDivisors( n ) ) break;
|
|
NSLog( @"The first abundant odd number above one billion is: %lu\n", n )
|
|
|
|
HandleEvents
|