Guest User

Untitled

a guest
Dec 10th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3.  
  4. #Program Name
  5. print("Prime Number Checker")
  6.  
  7.  
  8. def factor_count(num):
  9. factor_count = 0
  10. print("The factors are: ")
  11.  
  12. def main():
  13. choice = "y"
  14. while choice.lower() == "y":
  15. #user input
  16. num = int(input("Please enter a number: "))
  17. if num <= 1:
  18. print("please choose a value greater than 1. ")
  19. print()
  20. else:
  21. for i in range(1, num+1):
  22. if num%i == 0:
  23. print(i)
  24. if factor_count == 2:
  25. print(num, "is prime")
  26. else:
  27. print(num, "is not prime!")
  28.  
  29. if __name__ == "__main__" :
  30. main()
  31.  
  32.  
  33. print()
  34. print("goodbye")
  35.  
  36. def main():
  37. choice = "y"
  38. while choice.lower() == "y":
  39. factor_count = 0
  40. # user input
  41. num = int(input("Please enter a number: "))
  42. if num <= 1:
  43. print("please choose a value greater than 1. ")
  44. print()
  45. else:
  46. for i in range(2, num):
  47. if num % i == 0:
  48. print(i)
  49. factor_count += 1
  50. if factor_count == 0:
  51. print(num, "is prime")
  52. else:
  53. print(num, "is not prime!")
  54. choice = input('Do you want to continue?(y/n) : ')
  55.  
  56.  
  57. if __name__ == "__main__":
  58. print("Prime Number Checker")
  59. main()
  60. print()
  61. print("goodbye")
Add Comment
Please, Sign In to add comment