Menu Close

Fibonacci Series up to given n numbers

Program to print Fibonacci series up to given n numbers.

Num=int(input("Enter n Number: "))
s=1
temp1=0
temp=0

for i in range(Num):
	if(i<2):
		print(i)
	else:
		temp=temp1+s
		temp1=s
		s=temp
		print(temp)

Input:
         Enter n Number: 10
Output:
           0
           1
           1
           2
           3
           5
           8
           13
           21
           34


Output:
Enter n Number: 10
0
1
1
2
3
5
8
13
21
34

Output:
Enter n Number: 5
0
1
1
2
3

Output:
Enter n Number: 20
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181


More Codes to Fcuk

Explore