Find sum of the series 1 + 22 + 333 + 4444 + ... ... upto n terms | CPP program to find the sum of given series ; Function to calculate sum ; Return sum ; Driver code
#include <iostream> NEW_LINE #include <math.h> NEW_LINE using namespace std ; int findSum ( int n ) { return ( pow ( 10 , n + 1 ) * ( 9 * n - 1 ) + 10 ) / pow ( 9 , 3 ) - n * ( n + 1 ) / 18 ; } int main ( ) { int n = 3 ; cout << findSum ( n ) ; return 0 ; }