Check if N can be represented as sum of squares of two consecutive integers | Java 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 java . lang . Math ; class GFG { public static boolean isSumSquare ( int N ) { double n = ( 2 + Math . sqrt ( 8 * N - 4 ) ) / 2 ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int i = 13 ; if ( isSumSquare ( i ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }