1.

To generate the general no between 1to10 write the general syntax​

Answer»

number n, find sum of digits in all NUMBERS from 1 to n.  Examples:   Input: n = 5 Output: Sum of digits in numbers from 1 to 5 = 15 Input: n = 12 Output: Sum of digits in numbers from 1 to 12 = 51 Input: n = 328 Output: Sum of digits in numbers from 1 to 328 = 3241 Naive Solution:  A naive solution is to GO through every number x from 1 to n, and COMPUTE sum in x by traversing all digits of x. Below is the implementation of this idea.   filter_none



Discussion

No Comment Found