[Shootout-list] Fixed version of Fibonacci bench for Ada

Pascal Obry pascal@obry.net
Sat, 19 Mar 2005 09:23:49 +0100


Here is a new version that implements the Fibonacci bench.
It is smaller and gives correct output.

-- $Id: fibo-gnat.code,v 1.8 2005/03/19 07:50:14 bfulgham Exp $
-- http://dada.perl.it/shootout/
-- Contributed by Pascal Obry on 2005/03/19

with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line;
use  Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line;

procedure Fibo is

   function Fib (N : Natural) return Natural is
   begin
      if N <= 1 then
         return N;
      else
         return Fib (N - 2) + Fib (N - 1);
      end if;
   end Fib;

   N : Natural;
begin
   N := Natural'Value (Argument (1));
   Put (Item => Fib (N), Width => 0);
   New_Line;
end Fibo;

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