Trimorphic number



Cube the given number. If the given number is present in the cube number in last means, that is called Trimorphic number.



Example-1:



Input    : n = 5
Output   : Trimorphic number    
Explain  : 53 = 125



Example-2:



Input    : 24
Output   : Trimorphic number  
Explain  : 243 = 13824    



Example-3:



Input    : 3
Output   : Not a Trimorphic number  
Explain  : 33 = 27    







Solution




public class Main
{
    public static void main(String [] args)
    { 

        int n = 4;

        int cube = n*n*n;

        while(n!=0)
        {
            if(n%10!=cube%10)
            {
                System.out.print("Not a Trimorphic number");
                break;
            }

            n = n/10;

            cube = cube/10;
        }

        if(n==0)
        {
            System.out.print("Trimorphic number");
        }
    }
}
n = 4

d = str(n**3)

a = len(str(n))

if(d[-a:]==str(n)):

    print("Trimorphic number")

else:

    print("Not a Trimorphic number")



Output



Trimorphic number