jeudi 11 février 2021

My programs works but i don't know whether my source code is idle or not

I am learning python online and I wrote this code to find whether a number is prime number or not. The thing is what they did was very different from what I wrote in my code so can I get any suggestion to how to make my code more efficient or better? Also this isn't the only program I made there are many programs I am practicing and many of them work but I am doubting whether my method is correct and my coding is inefficient

n = int(input("Enter the number "))
c = 2
r= n%c
while(r>0):
    c = c+1
    r = n%c
if (c==n):
    print("The number is prime number");
else:
    print("The number you entered is not a prime number")
    print("it is divisible by ",c)

Aucun commentaire:

Enregistrer un commentaire