Calculate n + nn + nnn + ... + n(m times) in Python Last Updated : 05 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The program is to find a mathematical series, where we need to accept the value of n and m. n is the base number and m is the number of times till which the series run. Examples: Input : 2 + 22 + 222 + 2222 + 22222 Output : 24690 Input : 12 + 1212 + 121212 Output : 122436 We first convert the numbers into string format and concatenate them regularly. Later, we convert them back to integer and add them upto mth term. as shown in the following program. Python3 # Python program to sum the given series # Returns sum of n + nn + nnn + .... (m times) def Series(n, m): # Converting the number to string str_n = str(n) # Initializing result as number and string sums = n sum_str = str(n) # Adding remaining terms for i in range(1, m): # Concatenating the string making n, nn, nnn... sum_str = sum_str + str_n # Before adding converting back to integer sums = sums + int(sum_str) return sums # Driver Code n = 2 m = 5 total = Series(n, m) print(total) Output: 24690 Comment More infoAdvertise with us Next Article Itertools.accumulate()-Python C chinmoy lenka Follow Improve Article Tags : Python series large-numbers Practice Tags : pythonseries Similar Reads Multiply All Numbers in the List in Python Our task is Multiplying all numbers in a list Using Python. This can be useful in calculations, data analysis, and whenever we need a cumulative product. In this article we are going to explore various method to do this. Using a loopWe can simply use a loop (for loop) to iterate over the list elemen 2 min read Prefix Sum Array in Python using Accumulate Function A prefix sum array is an array where each element is the cumulative sum of all the previous elements up to that point in the original array. For example, given an array [1, 2, 3, 4], its prefix sum array would be [1, 3, 6, 10]. Let us explore various methods to achieve this.Using accumulate from ite 3 min read sum() function in Python The sum of numbers in the list is required everywhere. Python provides an inbuilt function sum() which sums up the numbers in the list. Pythonarr = [1, 5, 2] print(sum(arr))Output8 Sum() Function in Python Syntax Syntax : sum(iterable, start) iterable : iterable can be anything list , tuples or dict 3 min read Itertools.accumulate()-Python itertools.accumulate() is an iterator that takes two arguments, an iterable (target) and an optional function. The function is applied at each iteration to accumulate the result. By default, if no function is provided, it performs addition. If the input iterable is empty, the output will also be emp 3 min read Find sum of elements in List - Python Finding the sum of elements in a list means adding all the values together to get a single total. For example, given a list like [10, 20, 30, 40, 50], you might want to calculate the total sum, which is 150. Let's explore these different methods to do this efficiently.Using sum()sum() function is th 3 min read Find sum of elements in List - Python Finding the sum of elements in a list means adding all the values together to get a single total. For example, given a list like [10, 20, 30, 40, 50], you might want to calculate the total sum, which is 150. Let's explore these different methods to do this efficiently.Using sum()sum() function is th 3 min read Like