Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,32 @@
scope /* show members of the van der Corput sequence in various bases
translated from the C sample
*/
# returns the numerator and denominator of the nth member of the van der Corput sequence
# in the specified base
local procedure vc( nth :: number, base :: number )
local p, q, n := 0, 1, nth;
while n <> 0 do
p *:= base
p +:= n mod base
q *:= base
n \:= base
od;
# return the numerator and denominator reduced by their gcd
local num, denom := p, q;
q := numtheory.gcd( p, q );
return num \ q, denom \ q
end
# task
for b from 2 to 5 do
printf( "base %d:", b );
for i from 0 to 9 do
local n, d := vc( i, b );
if n <> 0 then printf( " %d/%d", n, d ) else printf( " 0" ) fi;
end
io.write( "\n" )
od
end

View file

@ -0,0 +1,35 @@
do --[[ show members of the van der Corput sequence in various bases
translated from the C sample
]]
local int = require( "int" ) -- RC integer module - includes gcd
-- returns the numerator and denominator of the nth member of the van der Corput sequence
-- in the specified base
local function vc( nth : number, base : number )
local p, q, n = 0, 1, nth
while n != 0 do
p *= base
p += n % base
q *= base
n //= base
end
num, denom = p, q
-- return the numerator and denominator reduced by their gcd
q = int.gcd( num, denom )
return num // q, denom // q
end
-- task
for b = 2, 5 do
io.write( $"base {b}:" )
for i = 0, 9 do
local n, d = vc( i, b )
io.write( if n != 0 then $" {n}/{d}" else " 0" end )
end
io.write( "\n" )
end
end

View file

@ -0,0 +1,18 @@
!YS-v0
defn main(b):
each n range(10):
say:
format '%.6f':
vdc: n b
defn vdc(n b):
loop n n, d 1, vdc 0.0:
if n > 0:
then:
d *=: b
r =: n % b
n .=: quot(b)
vdc +=: r / d
recur: n, d, vdc
else: vdc