• + 0 comments

    in c++:

    const int MOD = 1000000007;
    
    // Function to perform modular exponentiation
    long long modPow(long long base, long long exp, int mod) {
        long long result = 1;
        base = base % mod;
        while (exp > 0) {
            if (exp & 1) {
                result = (result * base) % mod;
            }
            exp >>= 1;
            base = (base * base) % mod;
        }
        return result;
    }
    
    // Function to calculate the sum of the series
    int summingSeries(long n) {
        long long result = modPow(n, 2, MOD);
        return result;
    }