Pascal Subprogram Of Fibonacci Series Using Function andrey пятница, 11 апреля 2014 г. No Comment

The Fibonacci series is one in which the addition of two previous terms gives you the next term. That is. 0,1,2,3,5,8,13....1 + 2 is the next consecutive term which is 3, so is 3 + 5 (8)the next term.

This program uses a function subprogram to call by value.

Program Fibnacci;
Var
I : integer;
Function fibonacci (a: integer): integer;
Begin
If a=1 then
   Fibonacci :=0
Else if n=2 then
    Fibonacci :=1
Else
    Fibonacci := Fibonacci(a-1) + Fibonacci (n-2);
End;
Begin
For I:= 1 to 20 do
Writeln(Fibonacci (I));
Readln
End.

The Fibonacci series is one in which the addition of two previous terms gives you the next term. That is. 0,1,2,3,5,8,13....1 + 2 is the next consecutive term which is 3, so is 3 + 5 (8)the next term.

This program uses a function subprogram to call by value.

Program Fibnacci;
Var
I : integer;
Function fibonacci (a: integer): integer;
Begin
If a=1 then
   Fibonacci :=0
Else if n=2 then
    Fibonacci :=1
Else
    Fibonacci := Fibonacci(a-1) + Fibonacci (n-2);
End;
Begin
For I:= 1 to 20 do
Writeln(Fibonacci (I));
Readln
End.

by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment