0

Hi,

I have to write a program that tests if a number entered is prime or not.

I have finished all the code to display input prompts and output message

Example: " Enter a number: " - " x is a prime number" - " x is not a prime number" etc

Does anyone know how to write the code to test if a number is prime or not?

I think I would have to divide the input number and check if it is equal to 0. If it is equal to 0 it would not be prime.

Something like this:

division = 2;

input / division

If( division == 0)

System.out.println( result + " is not a prime number");

I'm not sure.

Appreciate any help with this.

Thank you