Click the Twitter icon to follow our tweets and
know more about us.

Automorphic number via recursion

//program to check wether the entered number is automorphic or not(using recursion method)
class looplessautomorphic
{
    public static void main(int n)
    {
        int c=n*n;
        boolean ch=check(c,n);
        if(ch==true)
        System.out.println("Automorphic");
        else
        System.out.println("Not Automorphic");
    }
    public static boolean check(int c,int n)
    {
        boolean k;
        if(n==0)
        return true;
        else
        {
            k=check((c/10),(n/10));
            if((c%10)==(n%10) && k==true)
            return true;
            else
            return false;
        }
    }
}
------------------------OUTPUT-------------------
Enter number-: 625
Automorphic

Comments (0)

Post a Comment