We are uploading our contents, please refresh app.
Java Premium

Write A Program In Java Accept A Number From The User And Check Whether It Is A Automorphic Number Or Not Using pure(Return) Function.

An Automorphic number is a number whose square ends with the same digits as the original number. 

E.g – 25, 76, 376 etc.

Program:
import java.util.*; 
public class Automorphic_pure_fun 
{
    public int fun(int n)
    {
    int c=0,sqr=1,lastSquareDigits;
    sqr = n*n;
        while(n>0)
        {
            c++;
            n=n/10;
        }
        lastSquareDigits=(int)(sqr%(Math.pow(10,c)));
        return(lastSquareDigits);
    }
     public static void main(String args[])
      {
       int no,p,temp;
        Scanner sc= new Scanner(System.in);
        System.out.println("Enter a number");
        no=sc.nextInt();
        temp=no;
        Automorphic_pure_fun obj=new Automorphic_pure_fun ();
        p=obj.fun(no);
        if(p == temp)
        {
        System.out.println("Automorphic number");
        }
        else
        System.out.println("Not an Automorphic number");
    }
}
Output:
Enter a number
5
Automorphic number
 
Enter a number
12
Not an Automorphic number

Online user

Download our android app Download App Submit your query
x

Get Updates On

Java & Premium Programs

Java Solved & Questions

Java Coding easy to use

Proper Coding

Straight Into Your INBOX!

We are going to send you our resources for free. To collect your copy at first, join our mailing list. We are promising not to bother you by sending useless information. So don't miss any updates, stay connected!