Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Determining if a number is prime!

$
0
0
def isprime(n):
    n=abs(int(n))
    if n<2:
        return False
    elif n==2:
        return True
    for x in range(3,int(n**0.5)+1,2):
            if n % x == 0:
                return False
    return True

def main():
    number=int(input("Please enter a number:"))
    isprime(number)

main()


The program asks:
Please enter a number:
you enter the number then it stops
why is this happening?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>