Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with ada.Text_IO; use ada.Text_IO;
- procedure Fib
- is
- Store : array (1..45) of Integer;
- function fibonacci (N : in Integer) return Integer
- is
- Result : Integer;
- begin
- if N > 2 then
- Result := Store (N-2) + Store (N-1);
- elsif N = 2 then
- Result := 1;
- else
- Result := 0;
- end if;
- Store (N) := Result;
- return Result;
- end;
- the_fib : Integer;
- begin
- for Each in Store'range loop
- the_fib := fibonacci (Each);
- put_Line (Integer'Image (Each) & " => " & Integer'Image (Store (Each)));
- end loop;
- end;
Add Comment
Please, Sign In to add comment