Trimorphic Number | Function to check Trimorphic number ; Store the cube ; Start Comparing digits ; Return false , if any digit of N doesn ' t ▁ match ▁ with ▁ ▁ its ▁ cube ' s digits from last ; Reduce N and cube ; Driver code
function isTrimorphic ( N ) { let cube = N * N * N ; while ( N > 0 ) { if ( N % 10 != cube % 10 ) return false ; N = parseInt ( N / 10 , 10 ) ; cube = parseInt ( cube / 10 , 10 ) ; } return true ; } let N = 24 ; if ( isTrimorphic ( N ) == true ) document . write ( " " ) ; else document . write ( " " ) ;