Skip to content

Patch 1 #12797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Patch 1 #12797

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions dynamic_programming/Lucas_function
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#Giving the output
def lucas_func(n):
#PREDFINING THE VALUES
a = 2
b = 1

if n == 0:
return a

# GENERATING THE NUMBER
for i in range(2, n + 1):
c = a + b
a = b
b = c

return b

# USER INPUT
n = int(input("Enter the position n to find the nth Lucas Number: "))
print(f"The {n}th Lucas Number is: {lucas_func(n)}")

"""

THE OUTPUT:-
Enter the position n to find the nth Lucas Number: 6
The 6th Lucas Number is: 18

"""
Loading