forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lucas series added (TheAlgorithms#399)
- Loading branch information
1 parent
89f15be
commit 559951c
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Lucas Sequence Using Recursion | ||
|
||
def recur_luc(n): | ||
if n == 1: | ||
return n | ||
if n == 0: | ||
return 2 | ||
return (recur_luc(n-1) + recur_luc(n-2)) | ||
|
||
limit = int(input("How many terms to include in Lucas series:")) | ||
print("Lucas series:") | ||
for i in range(limit): | ||
print(recur_luc(i)) |