Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #coding:utf-8
- num = (int(input("Digite um nº: ")))
- primo = True
- if num == 0 or num ==1 or num == 2:
- primo = True
- else:
- if num % 2 == 0:
- primo = False
- else:
- inicio = 3
- while (inicio < num) and primo == True:
- if num % inicio == 0:
- primo = False
- else:
- inicio = inicio + 2
- primo = True
- if primo == True:
- print("O nº %d é primo!" %(num))
- else:
- print("O nº %d NÃO é primo!" %(num))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement