Sum of both diagonals of a spiral odd | function returns sum of diagonals ; as order should be only odd we should pass only odd - integers ; Driver Code
< ? php function spiralDiaSum ( $ n ) { if ( $ n == 1 ) return 1 ; return ( 4 * $ n * $ n - 6 * $ n + 6 + spiralDiaSum ( $ n - 2 ) ) ; } $ n = 7 ; echo spiralDiaSum ( $ n ) ; ? >