Sum of squares of first n natural numbers | Function to calculate sum ; Driver code
< ? php function summation ( $ n ) { $ sum = 0 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ sum += ( $ i * $ i ) ; return $ sum ; } $ n = 2 ; echo summation ( $ n ) ; ? >