About 9,280,000 results
Open links in new tab
  1. How to Print Prime Numbers from 1 to N in Python? - Python

    Oct 16, 2024 · Here is the complete Python code to print prime numbers from 1 to n in Python. if num <= 1: return False. for i in range(2, int(num**0.5) + 1): if num % i == 0: return False. return True. for num in range(2, n + 1): if is_prime(num): print(num)

  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 prime numbers.

  3. Python Program to Check Prime Number

    print(num, "is not a prime number") elif num > 1: # check for factors for i in range(2, num): if (num % i) == 0: # if factor is found, set flag to True . flag = True # break out of loop break # check if flag is True if flag: print(num, "is not a prime number") else: print(num, "is a prime number") Output.

  4. print prime numbers from 1 to 100 in python – allinpython.com

    In this post, we will learn how to print prime numbers in python from 1 to 100, 1 to n, and in a given interval but before we jump into a program let’s understand what is a prime number? 1 What is a prime number? 3 1. Write a python program to print prime numbers from 1 …

  5. Python Program to Check Prime Number (4 Ways)

    In this tutorial, you will learn to write a Python Program to Check Prime Number. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. In other words, a prime number is a number that is only divisible by 1 and itself.

  6. Python Programs to Check Prime Number - PYnative

    Mar 31, 2025 · Steps to check if a number is prime using Python: Initialization. Initialize a variable n with the number to check for prime number and is_prime flag to False. Handle edge cases. If the number is less than or equal to 1, it’s not prime. Return False. If the number is 2, it’s prime.

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

    Aug 19, 2021 · Here we are using math.sqrt to check if the number is prime or not. sqrt () is a built-in function in python. x – that can be any value. It returns the square root of the x value. Sympy is a module in the python library.

  8. Program to print prime numbers from 1 to N. - GeeksforGeeks

    Oct 8, 2024 · Algorithm to print prime numbers: First, take the number N as input. Then use a for loop to iterate the numbers from 1 to N; Then check for each number to be a prime number. If it is a prime number, print it. Approach 1: Print prime numbers using loop.

  9. Python Program to Print all Prime Numbers in an Interval

    Source code to print all prime numbers between two numbers enterd by user in Python programming with output and explanation...

  10. Python Program to Print Prime Numbers from 1 to 100 - Python

    Oct 20, 2024 · In this tutorial, I explained three methods to print prime numbers from 1 to 100 using Python, such as using a simple for loop, list comprehensions, or the Sieve of Eratosthenes. I hope all these examples help you.

  11. Some results have been removed
Refresh