SimeonTs

SUPyF2 D.Types and Vars More Exercises - 03. Prme Number Che

Sep 27th, 2019
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. """
  2. Data Types and Variables - More Exercises
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1723#2
  4.  
  5. SUPyF2 D.Types and Vars More Exercises - 03. Prme Number Checker
  6.  
  7. Problem:
  8. Write a program to check if a number is prime (only wholly divisible by itself and one).
  9. The input comes as a integer number.
  10. The output should be true for prime number and false otherwise.
  11.  
  12. Examples:
  13. Input:
  14. 7
  15. Output:
  16. True
  17.  
  18. Input:
  19. 8
  20. Output:
  21. False
  22. """
  23. num = int(input())
  24.  
  25. if num > 1:
  26.     for i in range(2, num):
  27.         if (num % i) == 0:
  28.             print("False")
  29.             break
  30.     else:
  31.         print("True")
  32.  
  33. else:
  34.     print("False")
Add Comment
Please, Sign In to add comment