Check if N can be represented as sum of squares of two consecutive integers | Python3 implementation to check that a number is sum of squares of 2 consecutive numbers or not ; Function to check that the a number is sum of squares of 2 consecutive numbers or not ; Condition to check if the a number is sum of squares of 2 consecutive numbers or not ; Driver code ; Function call
import math NEW_LINE def isSumSquare ( N ) : NEW_LINE INDENT n = ( 2 + math . sqrt ( 8 * N - 4 ) ) / 2 NEW_LINE return ( n - int ( n ) ) == 0 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT i = 13 NEW_LINE if isSumSquare ( i ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT DEDENT