# Find sum of the series 1+22+333+4444+…… upto n terms

Given a number N. The task is to find the sum of the below series up to N-th term:

1 + 22 + 333 + 4444 + …up to n terms

Examples:

Input: N = 3
Output: 356

Input: N = 10
Output: 12208504795


## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach:

Below is the implementation of the above approach:

## C++

 // CPP program to find the sum   // of given series     #include  #include     using namespace std;     // Function to calculate sum  int findSum(int n)  {      // Return sum      return (pow(10, n + 1) * (9 * n - 1) + 10) /                       pow(9, 3) - n * (n + 1) / 18;  }     // Driver code  int main()  {      int n = 3;         cout << findSum(n);             return 0;  }

## Java

 // Java Program to find   // Sum of first n terms  import java.util.*;     class solution  {  static int calculateSum(int n)  {     // Returning the final sum  return ((int)Math.pow(10, n + 1) * (9 * n - 1) + 10) /                   (int)Math.pow(9, 3) - n * (n + 1) / 18;  }     // Driver code  public static void main(String ar[])  {  // no. of terms to find the sum  int n=3;  System.out.println("Sum= "+ calculateSum(n));     }  }     //This code is contributed by Surendra_Gangwar

## Python 3

 # Python program to find the sum of given series.        # Function to calculate sum  def solve_sum(n):      # Return sum      return (pow(10, n + 1)*(9 * n - 1)+10)/pow(9, 3)-n*(n + 1)/18    # driver code  n = 3    print(int(solve_sum(n)))

## C#

 // C# Program to find   // Sum of first n terms  using System;  class solution  {  static int calculateSum(int n)  {     // Returning the final sum  return ((int)Math.Pow(10, n + 1) * (9 * n - 1) + 10) /                   (int)Math.Pow(9, 3) - n * (n + 1) / 18;  }     // Driver code  public static void  Main()  {  // no. of terms to find the sum  int n=3;  Console.WriteLine("Sum= "+ calculateSum(n));     }  }     //This code is contributed by inder_verma.

## PHP

 

Output:

356


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.