Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #Program Name
- print("Prime Number Checker")
- def factor_count(num):
- factor_count = 0
- print("The factors are: ")
- def main():
- choice = "y"
- while choice.lower() == "y":
- #user input
- num = int(input("Please enter a number: "))
- if num <= 1:
- print("please choose a value greater than 1. ")
- print()
- else:
- for i in range(1, num+1):
- if num%i == 0:
- print(i)
- if factor_count == 2:
- print(num, "is prime")
- else:
- print(num, "is not prime!")
- if __name__ == "__main__" :
- main()
- print()
- print("goodbye")
- def main():
- choice = "y"
- while choice.lower() == "y":
- factor_count = 0
- # user input
- num = int(input("Please enter a number: "))
- if num <= 1:
- print("please choose a value greater than 1. ")
- print()
- else:
- for i in range(2, num):
- if num % i == 0:
- print(i)
- factor_count += 1
- if factor_count == 0:
- print(num, "is prime")
- else:
- print(num, "is not prime!")
- choice = input('Do you want to continue?(y/n) : ')
- if __name__ == "__main__":
- print("Prime Number Checker")
- main()
- print()
- print("goodbye")
Add Comment
Please, Sign In to add comment