Thursday, October 6, 2022
Home PYTHON Recursive Function

# Recursive Function

### Python program to reverse a string using recursive

def reverse(str):   if len(str) == 0: return str else: ...

### Python program to check whether a string is a palindrome or not using recursive

def is_palindrome(st): if len(st) < 1: return True else: ...

### Python program to check number is prime or not using recursive

def prime_or_not(n, div = None): if div is None: div = n - 1 ...

### Python program to find the factorial of a number using recursive

def recur_factorial(num): if(num <= 1): return 1 else: ...

### Python program to check given number is even or odd using recursive

def check_even_odd(num): if (num < 2): return (num % 2 == 0) ...

### Python program to display the fibonacci sequence using recursive

def recursive_fibo(num): if num <= 1: return num else: ...

### Python program to find the product of two numbers using recursive

def mult_product(x,y): if(x<y): return mult_product(y,x) elif(y!=0): ...

### Python program to find the power of a number using recursive

def power(base,exp):   if(exp==1):      return(base)   if(exp!=1):      return(base*power(base,exp-1)) #____main_____ b=int(input("Please enter base: ")) e=int(input(" Please enter exponential...

### Python program to find the GCD of two numbers using recursive

def gcd(x,y):     if(y==0):       return x     else:       return gcd(y,x%y) x=int(input("Please enter first number: ")) y=int(input("Please enter second...

### Python program to check find the given year is a leap year or not

year=int(input("Please enter a year to be check leap year or not: ")) if(year%4==0 and year%100!=0 or year%400==0): print("This year is a leap...

### Python program to find the LCM of two numbers using recursive

def lcm(a,b): lcm.multiple=lcm.multiple+b if((lcm.multiple % a == 0) and (lcm.multiple % b == 0)): ...