1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Check for prime number

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024 às 10:42.

  1. Stack

    Stack Membro Participativo

    I'm using python to check if a number is prime or not, but when I write 15 it gave me True

    import math
    def isPrime(i):
    if i == 2 or i == 3:
    return True
    if i < 2:
    return False
    if i % 2 == 0:
    return False
    for j in range(3,int(math.sqrt(i))):
    if i % j == 0:
    return False
    return True
    while True:
    print(isPrime(int(input())))


    Are there any solutions?

    Continue reading...

Compartilhe esta Página