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
function sum ( N ) { let MOD = 1000000007 ; let val = N * ( N + 1 ) ; val = val % MOD ; return val ; } function sumX ( N , M , K ) { let MOD = 1000000007 ; for ( let i = 0 ; i < M ; i ++ ) { N = sum ( K + N ) ; } N = N % MOD ; return N ; } let N = 1 ; let M = 2 ; let K = 3 ; document . write ( sumX ( N , M , K ) ) ;