Hi all,
I'm trying to print out all prime numbers between 1 and 50 using just while and if statements but need some help
Can anyone give me an if statement that will print out the prime numbers.
here is my code so far but its not working correctly
public static void main(String [] args) {
int x, z;
x = 1;
z = 50;
while (x <= z)
{
if (x==2 || x/x==1 && x/1==x && x%2!=0 ) {System.out.println(x);}
x++;
}
Can anyone point out where I'm going wrong.
It might be a while before I reply but all replies will be answered.
Thanks