Data update
This commit is contained in:
parent
5af6d93694
commit
796d366b97
455 changed files with 7413 additions and 1900 deletions
35
Task/Attractive-numbers/FutureBasic/attractive-numbers.basic
Normal file
35
Task/Attractive-numbers/FutureBasic/attractive-numbers.basic
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
local fn IsPrime( n as NSUInteger ) as BOOL
|
||||
NSUInteger i
|
||||
|
||||
if ( n < 2 ) then exit fn = NO
|
||||
if ( n = 2 ) then exit fn = YES
|
||||
if ( n mod 2 == 0 ) then exit fn = NO
|
||||
for i = 3 to int(n^.5) step 2
|
||||
if ( n mod i == 0 ) then exit fn = NO
|
||||
next
|
||||
end fn = YES
|
||||
|
||||
local fn Factors( n as NSInteger ) as NSInteger
|
||||
NSInteger count = 0, f = 2
|
||||
|
||||
do
|
||||
if n mod f == 0 then count++ : n /= f else f++
|
||||
until ( f > n )
|
||||
end fn = count
|
||||
|
||||
void local fn AttractiveNumbers( limit as NSInteger )
|
||||
NSInteger c = 0, n
|
||||
|
||||
printf @"Attractive numbers through %d are:", limit
|
||||
for n = 4 to limit
|
||||
if fn IsPrime( fn Factors( n ) )
|
||||
printf @"%4d \b", n
|
||||
c++
|
||||
if ( c mod 10 == 0 ) then print
|
||||
end if
|
||||
next
|
||||
end fn
|
||||
|
||||
fn AttractiveNumbers( 120 )
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue