“Programa de Python de primer número” Código de respuesta

Programa de Python de primer número

#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##

Prime número en 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

Prime número en Python

a=int(input('number:'))
if a % 2 ==0 and a / 2 <= 2:
    print('composite')
elif a % 3 == 0 and a/3 <= 2:
    print('composit')
elif a % 5 == 0 and a/5 <= 2 :
    print('composit')
elif a % 7 == 0 and a/7 <= 2:
    print('composit')
else:
    print('prime')
________________________________________________________________________________
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 Python de primer número

#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##

Respuestas similares a “Programa de Python de primer número”

Preguntas similares a “Programa de Python de primer número”

Más respuestas relacionadas con “Programa de Python de primer número” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código