Showing posts with label fibonacci number in pascal. Show all posts
Showing posts with label fibonacci number in pascal. Show all posts

Friday, August 19, 2016

Fibonacci Numbers in Turbo Pascal

Here is a sample program that I wrote using Turbo Pascal For Windows to compute the fibonacci number based on the given number by the user.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.



 
Sample Program Output

Program Listing

Program Fibonacci;
Uses WinCrt;

Var N  : Integer;

Function fib(n:integer) : integer;
Begin
 If (n=0) OR (n=1) then
   Begin
   fib := 1;
   End
 Else
  fib:= fib(n-1)+fib(n-2);
End;

Begin
   Clrscr;
   Writeln('FIBONACCI NUMBERS IN PASCAL');
   Writeln;
   Write('Give a Number : ');
   Readln(n);
   Writeln;
   Writeln('The Fibonacci(n) = ',fib(n),'.');
   Readln;
End.