Learn practical skills, build real-world projects, and advance your career

Question 1

Write a function to return nth term of Fibonacci sequence.

def Fibonacci(n):
    fi = 1 
    se = 1 
    if n <= 2 :
        return 1 
    for i in range(2,n):
        val = fi + se 
        fi = se 
        se = val
    return val  

num = input("Enter value of n - ")
print("nth term Fibonacci is" , Fibonacci(int(num)))      
Enter value of n - 24 nth term Fibonacci is 46368

Question 2

Write a function to find out GCD of two numbers using EUCLID'S algorithm.