[Shootout-list] Harmonic bench for Ada
Pascal Obry
pascal@obry.net
Fri, 18 Mar 2005 19:53:49 +0100
Here is a fixed version of the Ada Harmonic bench.
-- The Great Computer Language Shootout
-- http://shootout.alioth.debian.org
--
-- Contributed by Jim Rogers
-- Fixed by Pascal Obry on 2005/03/18
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
procedure Harmonic is
Partial_Sum : Long_Float := 0.0;
N : Natural;
begin
N := Integer'Value (Argument (1));
for I in 1 .. N loop
Partial_Sum := Partial_Sum + (1.0 / Long_Float (I));
end loop;
Put (Item => Partial_Sum, Aft => 9, Exp => 0);
New_Line;
end Harmonic;
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595