To Find the Sum when a number is appended to itself n number of times in Python

Tharunkumar C Mar 01, 2021

Python program to calculate the sum when a number is appended to itself n number of times.

A number 'a' is given as the first input by the user. Another number 'n' is given as the second input. Initialize sum to 0. The number 'a' is appended 'n' times and the output of each iteration is added to sum(The value stored in sum is constantly updated). In the end, the sum value is printed as the output. 

For example:

If '8' is given as the first input and '5' is given as the second input.

Such that a=8, n=5

Now, sum=8+88+888+8888+88888 = 98760.

Project Files

Loading...
..
This directory is empty.

Comments (0)

Leave a Comment