Sum of the sequence 2 , 22 , 222 , ... ... ... | CPP program to find sum of series 2 , 22 , 222 , . . ; function which return the the sum of series ; driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float sumOfSeries ( int n ) { return 0.0246 * ( pow ( 10 , n ) - 1 - ( 9 * n ) ) ; } int main ( ) { int n = 3 ; cout << sumOfSeries ( n ) ; return 0 ; }