Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions Fibonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def fib(n): #Nth FIBONACCI number generator function
if n==1 or n==2: #1st and 2nd terms are 1
return 1
else:
return fib(n-1)+fib(n-2) #all other terms will be calculated recursively

n=int(input("Enter how many fibonacci terms you want to print: ")) #taking user input
print("The fibonacci series upto ",n,"th term is:-") #giving desired output
for i in range(1,n+1):
print(fib(i),end=" ") #looping till n terms and printing the terms as space seperated integers
8 changes: 8 additions & 0 deletions GCD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def gcd(a,b): #gcd function
while (b): #while b not equal to 0
a,b=b,a%b
return abs(a)

a,b=map(int,input("Enter 2 numbers: ").split()) #take user input of 2 numbers
c=gcd(a,b) #call the gcd function
print("The gcd of ",a," and ",b," is ",c) #output the result