Program to check if N is a Centered Cubic Number | Function to check if the number N is a centered cubic number ; Iterating from 1 ; Infinite loop ; Finding ith_term ; Checking if the number N is a Centered cube number ; If ith_term > N then N is not a Centered cube number ; Incrementing i ; Driver code ; Function call
function isCenteredcube ( N ) { let i = 1 ; while ( true ) { let ith_term = ( 2 * i + 1 ) * ( i * i + i + 1 ) ; if ( ith_term == N ) { return true ; } if ( ith_term > N ) { return false ; } i ++ ; } } let N = 9 ; if ( isCenteredcube ( N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }