Program to check if N is a Centered Cubic Number | Function to check if 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
def isCenteredcube ( N ) : NEW_LINE INDENT i = 1 ; NEW_LINE while ( True ) : NEW_LINE INDENT ith_term = ( ( 2 * i + 1 ) * ( i * i + i + 1 ) ) ; NEW_LINE if ( ith_term == N ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT if ( ith_term > N ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT i += 1 ; NEW_LINE DEDENT DEDENT N = 9 ; NEW_LINE if ( isCenteredcube ( N ) ) : NEW_LINE INDENT print ( " Yes " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) ; NEW_LINE DEDENT