Advertisement
Semior001

home work

Dec 6th, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.56 KB | None | 0 0
  1. type
  2.     row = file of integer;
  3.     vector = array[1..100] of integer;
  4. var
  5.     f: row;
  6.     fibonacci: vector;
  7.     n, size, i: integer;
  8. procedure fib(f:vector; n: integer);
  9. var
  10.     fibonacci: vector;
  11.     i,j: integer;
  12. begin
  13.     fibonacci[1] := 1;
  14.     fibonacci[2] := 1;
  15.     i:=3;
  16.     while fibonacci[i-1]+fibonacci[i-2] <= n do
  17.     begin
  18.         fibonacci[i] := fibonacci[i-1] + fibonacci[i-2];
  19.         i:=i+1;
  20.     end;
  21.     i:=i-1;
  22.     size:=i;
  23.     f:=fibonacci;
  24. end;
  25. begin
  26.     assign(f,'a.out');
  27.     rewrite(f);
  28.     readln(n);
  29.     fib(fibonacci,n);
  30.     for i:=1 to size do
  31.         write(f,fibonacci[i]);
  32.     close(f);
  33. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement