Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,37 @@
// Rosetta Code problem: https://rosettacode.org/wiki/Farey_sequence
// by Jjuanhdez, 06/2022
for i = 1 to 11
print "F", i, " = ";
farey(i, FALSE)
next i
print
for i = 100 to 1000 step 100
print "F", i;
if i <> 1000 then print " "; else print ""; : fi
print " = ";
farey(i, FALSE)
next i
end
sub 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 = cont + 1
if n < 12 then print a, "/", b, " "; : fi
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
cont = cont + 1
if n < 12 then print a, "/", b, " "; : fi
end while
if n < 12 then print else print cont using("######") : fi
end sub