Pascal Program For Calculating Fibonacci Numbers - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, September 23, 2017

Pascal Program For Calculating Fibonacci Numbers

Write an Pascal Program For Calculating  Fibonacci Numbers

Program:
var n,x0,x1,ans,i:integer;
begin
writeln(‘vuvedi chislo’);
readln(n);
x1:=1;
i:=1;
repeat
ans:=x0+x1;
x0:=x1;
x1:=ans;
i:=i+1;
until i=n;
writeln(ans);
readln;
end.

Output:
Enter the number of elements: 15

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

No comments:

Post a Comment