Check if N can be represented as sum of squares of two consecutive integers | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isSumSquare ( int N ) { float n = ( 2 + sqrt ( 8 * N - 4 ) ) / 2 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int i = 13 ; if ( isSumSquare ( i ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }