Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,27 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Main is
|
||||
package Float_IO is new Ada.Text_IO.Float_IO (Float);
|
||||
function Van_Der_Corput (N : Natural; Base : Positive := 2) return Float is
|
||||
Value : Natural := N;
|
||||
Result : Float := 0.0;
|
||||
Exponent : Positive := 1;
|
||||
begin
|
||||
while Value > 0 loop
|
||||
Result := Result +
|
||||
Float (Value mod Base) / Float (Base ** Exponent);
|
||||
Value := Value / Base;
|
||||
Exponent := Exponent + 1;
|
||||
end loop;
|
||||
return Result;
|
||||
end Van_Der_Corput;
|
||||
begin
|
||||
for Base in 2 .. 5 loop
|
||||
Ada.Text_IO.Put ("Base" & Integer'Image (Base) & ":");
|
||||
for N in 1 .. 10 loop
|
||||
Ada.Text_IO.Put (' ');
|
||||
Float_IO.Put (Item => Van_Der_Corput (N, Base), Exp => 0);
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end loop;
|
||||
end Main;
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
scope /* show members of the van der Corput sequence in various bases
|
||||
translated from the C sample
|
||||
*/
|
||||
* 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 proc vc( nth :: number, base :: number )
|
||||
local p, q, n := 0, 1, nth;
|
||||
|
||||
while n <> 0 do
|
||||
p *:= base
|
||||
p +:= n mod base
|
||||
q *:= base
|
||||
p *:= base;
|
||||
p +:= n mod base;
|
||||
q *:= base;
|
||||
n \:= base
|
||||
od;
|
||||
|
||||
|
|
@ -18,15 +18,15 @@ scope /* show members of the van der Corput sequence in various bases
|
|||
local num, denom := p, q;
|
||||
q := numtheory.gcd( p, q );
|
||||
return num \ q, denom \ q
|
||||
end
|
||||
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
|
||||
if n <> 0 then printf( " %d/%d", n, d ) else printf( " 0" ) fi
|
||||
od;
|
||||
io.write( "\n" )
|
||||
od
|
||||
end
|
||||
epocs
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
function vdc(integer n, atom base)
|
||||
atom vdc, denom, rem
|
||||
vdc = 0
|
||||
denom = 1
|
||||
while n do
|
||||
denom *= base
|
||||
rem = remainder(n,base)
|
||||
n = floor(n/base)
|
||||
vdc += rem / denom
|
||||
end while
|
||||
return vdc
|
||||
end function
|
||||
|
||||
for i = 2 to 5 do
|
||||
printf(1,"Base %d\n",i)
|
||||
for j = 0 to 9 do
|
||||
printf(1,"%g ",vdc(j,i))
|
||||
end for
|
||||
puts(1,"\n\n")
|
||||
end for
|
||||
|
|
@ -11,3 +11,11 @@ function vdc(n, base)
|
|||
end
|
||||
return m
|
||||
end
|
||||
for b = 2, 5 do
|
||||
io.write( "base ", b, ": " )
|
||||
for n = 0, 9 do
|
||||
local m = vdc(n, b)
|
||||
io.write(string.format("%0.4f ", m))
|
||||
end
|
||||
print()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
'http://rosettacode.org/wiki/Van_der_Corput_sequence
|
||||
'Van der Corput Sequence fucntion call = VanVanDerCorput(number,base)
|
||||
|
||||
Base2 = "0" : Base3 = "0" : Base4 = "0" : Base5 = "0"
|
||||
Base6 = "0" : Base7 = "0" : Base8 = "0" : Base9 = "0"
|
||||
|
||||
l = 1
|
||||
h = 1
|
||||
Do Until l = 9
|
||||
'Set h to the value of l after each function call
|
||||
'as it sets it to 0 - see lines 37 to 40.
|
||||
Base2 = Base2 & ", " & VanDerCorput(h,2) : h = l
|
||||
Base3 = Base3 & ", " & VanDerCorput(h,3) : h = l
|
||||
Base4 = Base4 & ", " & VanDerCorput(h,4) : h = l
|
||||
Base5 = Base5 & ", " & VanDerCorput(h,5) : h = l
|
||||
Base6 = Base6 & ", " & VanDerCorput(h,6) : h = l
|
||||
l = l + 1
|
||||
Loop
|
||||
|
||||
WScript.Echo "Base 2: " & Base2
|
||||
WScript.Echo "Base 3: " & Base3
|
||||
WScript.Echo "Base 4: " & Base4
|
||||
WScript.Echo "Base 5: " & Base5
|
||||
WScript.Echo "Base 6: " & Base6
|
||||
|
||||
'Van der Corput Sequence
|
||||
Function VanDerCorput(n,b)
|
||||
k = RevString(Dec2BaseN(n,b))
|
||||
For i = 1 To Len(k)
|
||||
VanDerCorput = VanDerCorput + (CLng(Mid(k,i,1)) * b^-i)
|
||||
Next
|
||||
End Function
|
||||
|
||||
'Decimal to Base N Conversion
|
||||
Function Dec2BaseN(q,c)
|
||||
Dec2BaseN = ""
|
||||
Do Until q = 0
|
||||
Dec2BaseN = CStr(q Mod c) & Dec2BaseN
|
||||
q = Int(q / c)
|
||||
Loop
|
||||
End Function
|
||||
|
||||
'Reverse String
|
||||
Function RevString(s)
|
||||
For j = Len(s) To 1 Step -1
|
||||
RevString = RevString & Mid(s,j,1)
|
||||
Next
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue