“Programa de números primos em python usando a função” Respostas de código

Prima em Python

from math import sqrt
for i in range(2, int(sqrt(num)) + 1):
    if num % i == 0:
        print("Not Prime")
        break
    print("Prime")

# Note: Use this if your num is big (ex. 10000 or bigger) for efficiency
# The result is still the same if the num is smaller
Old-fashioned Ostrich

Programa Python Número Prime

#prime number verification program
a=int(input('print number:'))
for i in range(2,a):
    if a%i !=0:
        continue
    else:
        print("Its not a prime number")
        break # here break is exicuted then it means else would not be exicuted.
else:
    print("Its a prime number")#this is out of the for loop suite.
        
Gr@Y_orphan_ViLL@in##

Primes Python

import math

def main():
    count = 3
    
    while True:
        isprime = True
        
        for x in range(2, int(math.sqrt(count) + 1)):
            if count % x == 0: 
                isprime = False
                break
        
        if isprime:
            print count
        
        count += 1
Thankful Tuatara

Programa de números primos em python usando a função

def prime(num):
  count=0
  if num>1:
   
     for i in range(2,int(input("Enter a number : "))+1):
              if i%num==0:
                 count=count+1
     if count==2:
         print(num,"is a prime Number"))
     else:
         print(num, "Is not prime number")
prime(29)
                 
Jolly Jackal

Respostas semelhantes a “Programa de números primos em python usando a função”

Perguntas semelhantes a “Programa de números primos em python usando a função”

Mais respostas relacionadas para “Programa de números primos em python usando a função” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código