Attractive numbers: Difference between revisions

Initial FutureBasic task solution added
(Attractive Numbers Program in Odin)
(Initial FutureBasic task solution added)
Line 1,541:
 
[[File:Fōrmulæ - Attractive numbers 03.png]]
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
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
</syntaxhighlight>
{{output}}
<pre>
Attractive numbers through 120 are:
4 6 8 9 10 12 14 15 18 20
21 22 25 26 27 28 30 32 33 34
35 38 39 42 44 45 46 48 49 50
51 52 55 57 58 62 63 65 66 68
69 70 72 74 75 76 77 78 80 82
85 86 87 91 92 93 94 95 98 99
102 105 106 108 110 111 112 114 115 116
117 118 119 120
 
</pre>
 
 
=={{header|Go}}==
729

edits