
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Program to calculate n+nm+nmm.......+n(m times).
Here n is given value which is positive number m is the number of times till which the series run. Our task is to calculate this series.
Algorithm
Step 1: Input n, m; Step 2: Converting the number to string. Step 3: Initializing result as number and string. Step 4: Adding remaining terms. Step 5: Concatenating the string making n, nn, nnn... Step 6: Before adding converting back to integer. Step 7: return sum.
Example Code
# Python program to sum the series def sumofseries(n, m): str1 = str(n) sum1 = n sumofstr1 = str(n) for i in range(1, m): sumofstr1 = sumofstr1 + str1 sum1 = sum1 + int(sumofstr1) return sum1 # Driver Code n = int(input("Enter the value of n")) m = int(input("Enter the value of m")) sumofno = sumofseries(n, m) print("SUM OF SERIES ::>",sumofno)
Output
Enter the value of n3 Enter the value of m5 SUM OF SERIES ::> 37035
- Related Articles
- Calculate n + nn + nnn + … + n(m times) in Python program
- Calculate n + nn + nnn + u + n(m times) in Python Program
- Calculate n + nn + nnn + ? + n(m times) in Python
- Python Program to Calculate Standard Deviation
- PHP program to calculate the total time given an array of times
- Program to check pattern of length m repeated K or more times exists or not in Python
- Python Program to calculate the area of Cube
- Python Program to calculate the volume of Cube
- Python Program to calculate the Round Trip Time (RTT)
- Python Program to calculate the area of a Tetrahedron
- Python Program to calculate the area of the rhombus
- Program to calculate vertex-to-vertex reachablity matrix in Python
- A godown measures $40\ m \times 25\ m \times 10\ m$. Find the maximum number of wooden crates each measuring $1.5\ m \times 1.25\ m \times 0.5\ m$ that can be stored in the godown.
- Use multiplication properties to calculate the following: $7\times( 100\times -12)$.
- Python Program to calculate the volume and area of Cone

Advertisements