Guest User

Untitled

a guest
Apr 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.66 KB | None | 0 0
  1. with Text_IO; use Text_IO;
  2. procedure fibo is
  3.     type IntArray is array(Natural range <>) of Integer;
  4.     type IntArrayPtr is access IntArray;
  5.     function fibor(arr0:IntArrayPtr;n:Integer) return Integer is
  6.     begin
  7.         if n = 0 or n = 1 then
  8.              arr0.all(n) := 1;
  9.             return 1;
  10.         else
  11.             arr0.all(n) := fibor(arr0,n-1)+fibor(arr0,n-2);
  12.             return fibor(arr0,n-1)+fibor(arr0,n-2);
  13.         end if;
  14.     end fibor;
  15.     arr1:IntArrayPtr := new IntArray(0..45);
  16.     temp:Integer;
  17. begin
  18.     temp := fibor(arr1,45);
  19.     for i in arr1'range loop
  20.         put_line(Integer'Image(arr1(i)));
  21.     end loop;
  22.  
  23. end fibo;
Add Comment
Please, Sign In to add comment