Brahmagupta Fibonacci Identity | Java code to verify Brahmagupta Fibonacci identity ; represent the product as sum of 2 squares ; check identity criteria ; Driver code ; 1 ^ 2 + 2 ^ 2 ; 3 ^ 2 + 4 ^ 2 ; express product of sum of 2 squares as sum of ( sum of 2 squares )
class GFG { static void find_sum_of_two_squares ( int a , int b ) { int ab = a * b ; for ( int i = 0 ; i * i <= ab ; i ++ ) { for ( int j = i ; i * i + j * j <= ab ; j ++ ) { if ( i * i + j * j == ab ) System . out . println ( i + " ^ 2 ▁ + ▁ " + j + " ^ 2 ▁ = ▁ " + ab ) ; } } } public static void main ( String [ ] args ) { int a = 1 * 1 + 2 * 2 ; int b = 3 * 3 + 4 * 4 ; System . out . println ( " Representation ▁ of ▁ a ▁ * ▁ b ▁ " + " as ▁ sum ▁ of ▁ 2 ▁ squares : " ) ; find_sum_of_two_squares ( a , b ) ; } }