-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sagar Paul
committed
Jun 6, 2021
1 parent
bc1ec41
commit 0b5e202
Showing
3 changed files
with
28 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
# Recursive fuction | ||
|
||
def feb(n): | ||
if n<=1: | ||
return n | ||
return feb(n-1) + feb(n-2) | ||
|
||
k = int(input(f"k = ")) | ||
|
||
for i in range(k): | ||
print(feb(i)) | ||
|
||
|
||
|
||
# Iterativr method for Fibonacci | ||
|
||
a = 0 | ||
b = 1 | ||
n = int(input()) | ||
print(a) | ||
print(b) | ||
for i in range(n-2): | ||
c = a+b | ||
a,b = b,c | ||
print(c) | ||
|
||
|
||
|
Empty file.