Question: Write a function nSum which takes one input, n, and finds the sunm n nn nnn + nnnn+up to n digits of n For example

 Write a function nSum which takes one input, n, and finds

Write a function nSum which takes one input, n, and finds the sunm n nn nnn + nnnn+up to n digits of n For example >>> print (nSum( 1) which is 1 = 1 >>> print (nSum( 2)) 24 Which is 2 + 22 = 24 >>> print (nSum( 3)) 369 Which is 3+33 333 369 >>> print (nSum( 4)) 4936 which is 4 + 44 + 444 + 4444 = 4936 >>> print (nSum 61725 which is 5 + 55 + 555 + 5555 + 55555 = 61725 5)) Hint: think about each element of the sum (3, 33, 333, for example) represented as a sum of powers of 10 333 = 3 * 10"O + 3 * 101 + 3 * 10"2 = 3 + 30 + 300 For example Test Result print (nSum(3))369 print (nSum(4)) 4936 print (nSum()) print (nSum(1)) 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!