-- $Id: fibo.gnat,v 1.0 2003/06/11 12:02:00 dada Exp $
-- http://dada.perl.it/shootout/
-- Ada 95 code by C.C.
with Ada.Command_Line, Ada.Text_IO, Ada.Integer_Text_IO;
procedure Fibo is
function Fib (N : Natural) return Integer is
L : Integer := N - 1;
pragma Suppress (Range_Check, On => L);
begin
if L <= 0 then
return 1;
else
return Fib (N - 2) + Fib (L);
end if;
end Fib;
N : Natural := 0;
begin
begin
N := Natural'Value (Ada.Command_Line.Argument (1));
exception
when Constraint_Error => null;
end;
Ada.Integer_Text_IO.Put (Item => Fib (N), Width => 0);
Ada.Text_IO.New_Line;
end Fibo;