Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/Farey-sequence/FutureBasic/farey-sequence.basic
Normal file
43
Task/Farey-sequence/FutureBasic/farey-sequence.basic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local fn FareySequence( n as long, descending as BOOL )
|
||||
long a = 0, b = 1, c = 1, d = n, k = 0
|
||||
long aa, bb, cc, dd
|
||||
long count = 0
|
||||
|
||||
if descending = YES
|
||||
a = 1
|
||||
c = n -1
|
||||
end if
|
||||
|
||||
count++
|
||||
if n < 12 then print a; "/"; b; " ";
|
||||
|
||||
while ( (c <= n) and not descending ) or ( (a > 0) and descending)
|
||||
aa = a
|
||||
bb = b
|
||||
cc = c
|
||||
dd = d
|
||||
k = int( (n + b) / d )
|
||||
a = cc
|
||||
b = dd
|
||||
c = k * cc - aa
|
||||
d = k * dd - bb
|
||||
count++
|
||||
if n < 12 then print a;"/"; b; " ";
|
||||
wend
|
||||
|
||||
if n < 12 then print else print count
|
||||
end fn
|
||||
|
||||
long i
|
||||
|
||||
for i = 1 to 11
|
||||
if i < 10 then printf @" F%ld = \b", i else printf @"F%ld = \b", i
|
||||
fn FareySequence( i, NO )
|
||||
next
|
||||
print
|
||||
for i = 100 to 1000 step 100
|
||||
if i < 1000 then printf @" F%ld = \b", i else printf @"F%ld = \b", i
|
||||
fn FareySequence( i, NO )
|
||||
next
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue