Created
September 30, 2021 01:34
-
-
Save RajeshKrSahoo/2bfb4df8a6ce69a856942ee42abd4529 to your computer and use it in GitHub Desktop.
print fiboncaii base on row number input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
--public