“code python pour imprimer des nombres premiers” Réponses codées

Programme Python pour trouver n nombres premiers

num = 10
for i in range(2,num+1):
    for j in range(2,i):
        if(i%j == 0):
            break
    else:
        print(i)
GrepDAD

Programme Python pour imprimer des nombres premiers dans un intervalle

lower = 800
upper = 900
print("Print the number's from ",lower," and ",upper,".")
for num in range(lower,upper + 1):
  if num > 1:
    for i in range(2, num):
      if (num % i) == 0:
        break
    else:
      print(num)    
Exuberant Elk

code python pour imprimer des nombres premiers

# Thanks to https://www.codegrepper.com/profile/farid
# Just tune his answer into easy to use function

def prime_numbers(start_num, end_num):
    for number in range(start_num , end_num + 1):
        is_prime = True
        for counter in range(2,number):
            value = number % counter
            if value == 0:
                is_prime = False
                break
        if is_prime == True:
            print(number)
mathiasgodwin

nombres premiers python

def is_prime(n):
  for i in range(2,n):
    if (n%i) == 0:
      return False
  return True
Atanas Atanasov

Numéro premier dans Python

start_num , end_num = input("enter 2 number sepreted by ,:").split(",")
start_num , end_num = int(start_num) , int(end_num)

for number in range(start_num , end_num+1):
    is_prime = True
    for counter in range(2,number):
        value = number % counter
        if value == 0:
            is_prime = False
            break
    if is_prime == True:
        print(number)
Fawlid

Programme Prime Number Python

#prime number or composit number
number=int(input('print number:'))
a=1
while number>a:
    if number%a ==0:
        a+=1
        print("Its composit 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##

Réponses similaires à “code python pour imprimer des nombres premiers”

Questions similaires à “code python pour imprimer des nombres premiers”

Plus de réponses similaires à “code python pour imprimer des nombres premiers” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code