Almost prime: Difference between revisions

Content added Content deleted
m (→‎{{header|RPL}}: formatting)
(Initial FutureBasic task solution added)
Line 2,385: Line 2,385:
in map f (1...m)
in map f (1...m)
</syntaxhighlight>
</syntaxhighlight>


=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
local fn K_Prime( n as long, k as long ) as BOOL
long f = 0, i = 0
BOOL result
for i = 2 to n
while ( n mod i == 0 )
if f = k then exit fn = NO
f += 1
n /= i
wend
next
result = f = k
end fn = result


long i, c, k

for k = 1 to 5
printf @"k = %ld:\b", k
i = 2
c = 0
while ( c < 10 )
if ( fn K_Prime( i, k ) )
printf @"%4ld\b", i
c++
end if
i++
wend
print
next

HandleEvents
</syntaxhighlight>
{{output}}
<pre>
k = 1 : 2 3 5 7 11 13 17 19 23 29
k = 2 : 4 6 9 10 14 15 21 22 25 26
k = 3 : 8 12 18 20 27 28 30 42 44 45
k = 4 : 16 24 36 40 54 56 60 81 84 88
k = 5 : 32 48 72 80 108 112 120 162 168 176
</pre>


=={{header|Go}}==
=={{header|Go}}==