Summing the sum series | C ++ program to calculate the terms of summing of 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
#include <iostream> NEW_LINE using namespace std ; # define MOD  1000000007 NEW_LINE long sum ( long N ) { long val = N * ( N + 1 ) ; val = val % MOD ; return val ; } int sumX ( int N , int M , int K ) { for ( int i = 0 ; i < M ; i ++ ) { N = ( int ) sum ( K + N ) ; } N = N % MOD ; return N ; } int main ( ) { int N = 1 , M = 2 , K = 3 ; cout << sumX ( N , M , K ) << endl ; return 0 ; }