Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/Farey-sequence/BASIC256/farey-sequence.basic
Normal file
34
Task/Farey-sequence/BASIC256/farey-sequence.basic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
for i = 1 to 11
|
||||
print "F"; i; " = ";
|
||||
call farey(i, FALSE)
|
||||
next i
|
||||
print
|
||||
for i = 100 to 1000 step 100
|
||||
print "F"; i;
|
||||
if i <> 1000 then print " "; else print "";
|
||||
print " = ";
|
||||
call farey(i, FALSE)
|
||||
next i
|
||||
end
|
||||
|
||||
subroutine farey(n, descending)
|
||||
a = 0 : b = 1 : c = 1 : d = n : k = 0
|
||||
cont = 0
|
||||
|
||||
if descending = TRUE then
|
||||
a = 1 : c = n -1
|
||||
end if
|
||||
|
||||
cont += 1
|
||||
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 = (n + b) \ d
|
||||
a = cc : b = dd : c = k * cc - aa : d = k * dd - bb
|
||||
cont += 1
|
||||
if n < 12 then print a; "/"; b; " ";
|
||||
end while
|
||||
|
||||
if n < 12 then print else print rjust(cont,7)
|
||||
end subroutine
|
||||
Loading…
Add table
Add a link
Reference in a new issue