For every program, there should be a softcopy file containing (i) Algorithm/Flowchart, (ii)
Source Code, (iii) Output
Q.2.Write a program to display the first n terms of Fibonacci series.
N = int(input("Enter No. of terms of fibonacci series: "))
a = 0
b = 1
print("Terms of Fibonacci Series:")
print("Term-1 = %d"%a)
print("Term-2 = %d"%b)
for r in range(2,N):
c = a+b
a=b
b=c
print("Term-%2d = %d"%(r+1,c))
Flow Chart
Output
Pseudo Code
Pseudo code (Fibonacci Series)
- Get the no. of terms of Fibonacci Series (N)
- First Term a=0
- Second Term b = 1
- Initialize a for loop from n=2 to N
- Get the next term c = a+b
- Update a = b and b = c
- If n < N, repeat the above step
- Diplay Fibonacci Series
Comments
Leave a comment