Recursive programs
Recursive programs
def a_function():
return True
output = a_function()
print(output)
2. Python Program for checking a number is bigger than one using boolean function
def is_bigger_than_one(number):
if number > 1:
return True
else:
return False
num=int(input("Enter a value:"))
print(is_bigger_than_one(num))
3. Python Program for checking a number is divisible by another using boolean function
4. Python Program for checking a number is prime or not using boolean function
def isprime(num):
if num> 1:
for n in range(2,num):
if (num % n) == 0:
return False
return True
else:
return False
num=int(input("Enter a number:"))
print(isprime(num))
5. Python Program to print the factorial of a number
def factorial(n):
if n == 1:
return n
else:
return n * factorial(n-1)
def recursive_fibonacci(n):
if n <= 1:
return n
else:
return(recursive_fibonacci(n-1) + recursive_fibonacci(n-2))