Need help almost finished problem thats due

Ok so the program I am writing is-

a program that stores a number in an integer variable x. The program then prints all the numbers from x to 1 that ends with either 3 or 5 or 7.

So far I have-

import javax.swing.JOptionPane;

public class C2{

public static void main ( String [] a)

{

String T = JOptionPane.showInputDialog(null, "Insert Number Here:");

int x = Integer.parseInt(T);

int counter= x;

while (counter>=1)

{

counter=counter-1;

{

if(x%10)

System.out.println(x);

}

}

}

}

The If statement is wrong, I know that mod 10 is how you get the last digit of a number but i cannot use it in my program correctly.

Please help