Someone asked me We know that \$12^2 = 144\$ and that \$38^2 = 1444\$. Are there any other perfect squares in the form?Here is my code:public class OneFours {public static void main(String args[]) {    final int power_of_ten = 8;    int num = 14;    for (int i = 0; i <= Math.pow(10, power_of_ten); i++) {        if (Math.pow((int) Math.sqrt(num), 2) == num) {            System.out.println(num +  is a perfect square with root                     + Math.sqrt(num));        }        if (i % (Math.pow(10, power_of_ten) / 100) == 0)            System.out.println(--- Progress                     + (int)((i / Math.pow(10, power_of_ten)) * 100) + % complete);        num = num * 10 + 4;    }}}
Finding whether a number of the form 1444....4 is a perfect square
java;mathematics
I suggest you modularize your code writing a function to check for perfect squares:public static boolean isPerfectSquare(int n) {    return Math.pow((int) Math.sqrt(n), 2) == n;}And you then you can call it:if (isPerfectSquare(num)) {                System.out.println(num +  is a perfect square with root                     + Math.sqrt(num));            }You should also take care of always putting braces, namely    if (i % (Math.pow(10, power_of_ten) / 100) == 0)        System.out.println(--- Progress                 + (int)((i / Math.pow(10, power_of_ten)) * 100) + % complete);should become    if (i % (Math.pow(10, power_of_ten) / 100) == 0) {        System.out.println(--- Progress                 + (int)((i / Math.pow(10, power_of_ten)) * 100) + % complete);    }typing braces takes  a fraction of a second, fixing bugs caused by not writing them may take hours.And make sure you get your indentation correct, after some tweaking in my ide I your code looks like this:public class OneFours {    public static boolean isPerfectSquare( int n) {        return Math.pow((int) Math.sqrt(n), 2) == n;    }    public static void main(String args[]) {        final int power_of_ten = 8;        int num = 14;        for (int i = 0; i <= Math.pow(10, power_of_ten); i++) {            if (isPerfectSquare(num)) {                System.out.println(num +  is a perfect square with root                     + Math.sqrt(num));            }            if (i % (Math.pow(10, power_of_ten) / 100) == 0) {                System.out.println(--- Progress                     + (int)((i / Math.pow(10, power_of_ten)) * 100) + % complete);            }            num = num * 10 + 4;        }    }}