About 13,700,000 results
Open links in new tab
  1. Python Program to Check Prime Number using While Loop

    Here is a simple example of how you can use a while loop to check if a number is prime or not in Python: def is_prime(n): if n <= 1: return False i = 2 while i*i <= n: if n % i == 0: return False i …

  2. Check Prime Number in Python - GeeksforGeeks

    Apr 10, 2025 · isprime () function from the SymPy library checks if a number is prime or not. It prints False for 30, True for 13 and True for 2 because 30 is not prime, while 13 and 2 are …

  3. 6 Best Ways To Check If Number Is Prime In Python

    Aug 19, 2021 · 2. How to check if the number is prime or not using loops? To check if a number is prime or not. We have to create a for loop to iterate the numbers. Suppose the number is …

  4. Python while loop for finding prime numbers - Stack Overflow

    inp = int(input("Enter the number: ")) isDiv = False i = 2 while i < inp: if inp%i ==0: isDiv = True print(f"{inp} is divisible by {i}.") i+=1 if isDiv: print(f"Hence {inp} is not a prime number.") else: …

  5. How to Find Prime Numbers in Python using While Loop

    How to Find Prime Numbers in Python using While Loop. In this Python tutorial, I want to share source codes of a simple Python program which identifies whether a number is a prime …

  6. How to Print Prime Numbers from 1 to N in Python? - Python

    Oct 16, 2024 · Method 1: Basic While Loop with Prime Check Function. This method uses a while loop to iterate through numbers and a helper function to check if a number is prime. Example: …

  7. Python Program to Check Prime Number

    We check if num is exactly divisible by any number from 2 to num - 1. If we find a factor in that range, the number is not prime, so we set flag to True and break out of the loop. Outside the …

  8. Python Program to find Prime Number - Tutorial Gateway

    Write a Python Program to Find Prime Number using For Loop, While Loop, and Functions. Any natural number that is not divisible by any other except 1 and itself is called a Prime. The list …

  9. Prime Number Program in Python using while loop - Coding …

    Oct 21, 2022 · In this program, we will find whether the given number is prime or not. We will use the while loop to check that the given number is divisible by any number between 2 and the …

  10. Python Program To Check Prime Number Using While Loop

    In this tutorial, you will learn to write a Python Program To Check Prime Number Using While Loop. A prime number is a positive integer greater than 1 that has no positive integer divisors …

Refresh