Summing the sum series | Function to calculate twice of sum of first N natural numbers ; Function to calculate the terms of summing of sum series ; Driver Code
< ? php function sum ( $ N ) { $ MOD = 1000000007 ; $ val = $ N * ( $ N + 1 ) ; $ val = $ val % $ MOD ; return $ val ; } function sumX ( $ N , $ M , $ K ) { $ MOD = 1000000007 ; for ( $ i = 0 ; $ i < $ M ; $ i ++ ) { $ N = sum ( $ K + $ N ) ; } $ N = $ N % $ MOD ; return $ N ; } $ N = 1 ; $ M = 2 ; $ K = 3 ; echo ( sumX ( $ N , $ M , $ K ) ) ; ? >