Python program to check number is prime or not using recursive

0
455
def prime_or_not(n, div = None):
    if div is None:
        div = n - 1
    while div >= 2:
        if n % div == 0:
            print("Given number is not prime")
            return False
        else:
            return prime_or_not(n, div-1)
    else:
        print("Given number is prime")
        return 'True'
num=int(input("Please enter a number: "))
prime_or_not(num)

      Output 1:
             Please enter a number: 7
             Given number is prime
      Output 2:
             Please enter a number: 18
             Given number is not prime

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

 

 

 

Python program to check number is prime or not using recursive program to check number is prime or not using recursive in python write a python program to check number is prime or not using recursive write a program to check number is prime or not using recursive write a program to check number is prime or not using recursive in python program to check number is prime or not using recursive check number is prime or not using recursive check number is prime or not using recursion Python program to check number is prime or not using recursion Python program to check number is prime or not using recursion in python write a python program to check number is prime or not using recursion python program to check a number is prime or not using recursion python program to check whether a number is prime or not using recursion python program to check if a number is prime or not using recursion python program to check if a number is prime or not using recursive program to check if a number is prime or not using recursion write a python program to check whether a number is prime or not using recursion write a python program to check whether a number is prime or not using recursive program to check prime or not using recursion program to check prime or not using recursive python program to check prime or not using recursion python program to check prime or not using recursive

LEAVE A REPLY

Please enter your comment!
Please enter your name here