0
solution?
Wria program that asks the user to inputs an integer and decides whether it is a prime number or not. Also prompt that whether the user wants to keep continue or not (Y/N). If the user enters Y the program should provide another chance to test a number, otherwise exits.
2 Answers
+ 2
If you need help with determining primality, then I have some code on my profile (written in Python, but I'm sure a translation isn't too hard). As for the rest, it shouldn't be too hard.
0
A number is prime if it is only divisible by 1 and itself. With 2 being a special case, all other positive even numbers are not prime because they are divisible by 2. If something is divisible by another number, the remainder will be 0. To find the remainder, we use the % or mod symbol. After getting the input, you can check if the number you got is divisible by 1, itself, and no other single digit. If those conditions are met, you have a prime.
For running the same code multiple times, put your code in a loop of your choice that continues will the user enters Y. Let me know if you need more help than that.



