Skip to content

Instantly share code, notes, and snippets.

@RajeshKrSahoo
Created September 30, 2021 01:34
Show Gist options
  • Save RajeshKrSahoo/2bfb4df8a6ce69a856942ee42abd4529 to your computer and use it in GitHub Desktop.
Save RajeshKrSahoo/2bfb4df8a6ce69a856942ee42abd4529 to your computer and use it in GitHub Desktop.
print fiboncaii base on row number input
##Python program to print fibonacci base on row number
from functools import lru_cache
@lru_cache(maxsize=1000)
def fibonacci(n):
if n==0:
return 0
if n==1:
return 0
elif n==2:
return 1
else:
return fibonacci(n-1)+fibonacci(n-2)
def printRowFib(rownum):
k=1
for i in range(1,rownum+1):
for j in range(0,i):
if rownum==i:
print(fibonacci(k),end=' ')
k+=1
# print('\n')
printRowFib(rownum=3)
@RajeshKrSahoo
Copy link
Author

--public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment