Showing posts with label trimorphic-number. Show all posts
Showing posts with label trimorphic-number. Show all posts

Friday, July 31, 2020

Write a program to input a number and check whether it is Trimorphic Number or not? (5^3=125, number is present in the last)

66)  Write a program to input a number and check whether it is Trimorphic Number or not? (53=125, number is present in the last)


import java.util.*;
public class Trimorphic
{
    public static void main(String args[ ])
   {
              Scanner sc = new Scanner (System.in);
              System.out.println("Enter a number");
              int a = sc.nextInt();
              int k = a;
              int c = 0;
              while(k>0)
              {
                  k=k/10;
                  c++;
              }
              int p = a*a*a;
              int x = (int)Math.pow(10,c);
              int m = p%x;
              if(m==a)
              {
                  System.out.println("Entered number is a TRIMORPHIC Number");
              }
              else
              {
                  System.out.println("Entered number is not a TRIMORPHIC Number");
              }
   }
}

Output : 



 jhvghvgk ;nkjn ,nkjhj