Euler 's Four Square Identity | function to check euler four square identity ; loops checking the sum of squares ; sum of 2 squares ; sum of 3 squares ; sum of 4 squares ; product of 2 numbers represented as sum of four squares i , j , k , l ; product of 2 numbers a and b represented as sum of four squares i , j , k , l ; given numbers can be represented as sum of 4 squares By euler 's four square identity product also can be represented as sum of 4 squares
< ? php function check_euler_four_square_identity ( $ a , $ b , $ ab ) { $ s = 0 ; for ( $ i = 0 ; $ i * $ i <= $ ab ; $ i ++ ) { $ s = $ i * $ i ; for ( $ j = $ i ; $ j * $ j <= $ ab ; $ j ++ ) { $ s = $ j * $ j + $ i * $ i ; for ( $ k = $ j ; $ k * $ k <= $ ab ; $ k ++ ) { $ s = $ k * $ k + $ j * $ j + $ i * $ i ; for ( $ l = $ k ; $ l * $ l <= $ ab ; $ l ++ ) { $ s = $ l * $ l + $ k * $ k + $ j * $ j + $ i * $ i ; if ( $ s == $ ab ) { echo ( " i ▁ = ▁ " . $ i . " STRNEWLINE " ) ; echo ( " j ▁ = ▁ " . $ j . " STRNEWLINE " ) ; echo ( " k ▁ = ▁ " . $ k . " STRNEWLINE " ) ; echo ( " l ▁ = ▁ " . $ l . " STRNEWLINE " ) ; echo " " . " Product ▁ of ▁ " . $ a . " ▁ and ▁ " . $ b ; echo " ▁ can ▁ be ▁ written " . " ▁ as ▁ sum ▁ of ▁ squares ▁ of ▁ i , ▁ " . " j , ▁ k , ▁ l STRNEWLINE " ; echo $ ab . " ▁ = ▁ " ; echo $ i . " * " ▁ . ▁ $ i . ▁ " + " echo $ j . " * " . $ j . " ▁ + ▁ " ; echo $ k . " * " ▁ . ▁ $ k ▁ . ▁ " + " echo $ l . " * " . $ l . " STRNEWLINE " ; echo " STRNEWLINE " ; } } } } } } $ ab = $ a * $ b ; check_euler_four_square_identity ( $ a , $ b , $ ab ) ; ? >