Question: **In Java** Write a program that initializes a variable n to some value and then determines if n is a prime number. A prime number
**In Java**
Write a program that initializes a variable n to some value and then determines if n is a prime number. A prime number is one that is not divisible by anything other then itself and 1. For example, 3, 5, 7, 11, 13. 17, 19, 23 are prime numbers. 2, 4, 6, 9, 21 are not prime numbers. Your program should print a message like:
Number 7 is a prime number
or
Number 8 is NOT a prime number
Change n to test if your program with different values to make sure it works correctly. Here are some prime numbers for you to test your program:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
