Frobenius numbers: Difference between revisions

Initial post
(Initial post)
Line 792:
25 9599
</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
local fn IsPrime( n as long ) as BOOL
long i
BOOL result = YES
if ( n < 2 ) then result = NO : exit fn
for i = 2 to n + 1
if ( i * i <= n ) and ( n mod i == 0 )
result = NO : exit fn
end if
next
end fn = result
 
void local fn ListFrobenius( upperLimit as long )
long i, pn = 2, n = 0, f, r = 0
NSLog( @"Frobenius numbers through %ld:", upperLimit )
for i = 3 to upperLimit - 1 step 2
if ( fn IsPrime(i) )
n++
f = pn * i - pn - i
if ( f > upperLimit ) then break
NSLog( @"%7ld\b", f )
r++
if r mod 5 == 0 then NSLog( @"" )
pn = i
end if
next
end fn
 
fn ListFrobenius( 100000 )
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Frobenius numbers through 100000:
1 7 23 59 119
191 287 395 615 839
1079 1439 1679 1931 2391
3015 3479 3959 4619 5039
5615 6395 7215 8447 9599
10199 10811 11447 12095 14111
16379 17679 18767 20423 22199
23399 25271 26891 28551 30615
32039 34199 36479 37631 38807
41579 46619 50171 51527 52895
55215 57119 59999 63999 67071
70215 72359 74519 77279 78959
82343 89351 94859 96719 98591
</pre>
 
 
=={{header|Go}}==
715

edits