Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Van-der-Corput-sequence/Ada/van-der-corput-sequence.ada
Normal file
27
Task/Van-der-Corput-sequence/Ada/van-der-corput-sequence.ada
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue