Split N ^ 2 numbers into N groups of equal sum | Function to print N groups of equal sum ; No . of Groups ; n / 2 pairs ; Driver code
< ? php function printGroups ( $ n ) { $ x = 1 ; $ y = $ n * $ n ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { for ( $ j = 1 ; $ j <= $ n / 2 ; $ j ++ ) { echo " { " ▁ , ▁ $ x ▁ , ▁ " , " ▁ , ▁ $ y ▁ , ▁ " } " $ x ++ ; $ y -- ; } echo " STRNEWLINE " ; } } $ n = 4 ; printGroups ( $ n ) ; ? >