Data update

This commit is contained in:
Ingy döt Net 2023-09-16 17:28:03 -07:00
parent 5af6d93694
commit 796d366b97
455 changed files with 7413 additions and 1900 deletions

View file

@ -1,18 +1,17 @@
proc vdc b n . v .
func vdc b n .
s = 1
v = 0
while n > 0
s *= b
m = n mod b
v += m / s
n = n div b
.
return v
.
for b = 2 to 5
write "base " & b & ":"
for n range0 10
call vdc b n v
write " " & v
write " " & vdc b n
.
print ""
.

View file

@ -0,0 +1,27 @@
function vdc( nth, base ) -- returns the numerator & denominator of the sequence element n in base
local p, q, n = 0, 1, nth
while n ~= 0 do
p = p * base
p = p + n % base;
q = q * base;
n = math.floor( n / base )
end
local num, denom = p, q;
-- reduce the numerator and denominator by their gcd
while p ~= 0 do
n = p
p = q % p
q = n
end
num = math.floor( num / q )
denom = math.floor( denom / q )
return num, denom
end
for b = 2,5 do
io.write( "base ", b, ": " )
for n = 0,9 do
local num, denom = vdc( n, b )
io.write( " ", num ) if num ~= 0 then io.write( "/", denom ) end
end
io.write( "\n" )
end