@SuppressWarnings("ALL")
/**
 * Sample exercise for Lab 1.
 */
public class FindNumber {

    /**
     * Tries to find a four digit number that, when reversed, is exactly four times larger. Prints
     * to console if found. Searches a very narrow range for easier debugging.
     */
    public static void main(String[] args) {
        for (int i = 2175; i < 2180; i++) {
            String reversedString = reverse(i);
            int times4 = i * 4;
            String compString = new String("" + times4);
            if (reversedString == compString) {
                System.out.println("Found Number: " + i);
            }
        }
    }

    /**
     * Returns a string that represents the input with all digits reversed
     */
    public static String reverse(int x) {
        String str = new String("" + x);
        String newStr = "";
        for (int i = str.length() - 1; i >= 0; i--) {
            newStr += str.charAt(i);
        }
        return newStr;
    }
}
