Question: code javascript: B n g i Given an integer N , find the smallest integer whose digits sum to N . Task description Write a

code javascript: Bn gi
Given an integer N, find the smallest integer whose digits sum to N.
Task description
Write a function solution that, given integer N, returns the smallest non-negative integer whose individual digits sum to N.
Examples:
1. Given N =16, the function should return 79. There are many numbers whose digits sum to 16(for example: 79,97,808,5551,22822, etc.). The smallest such number is 79.
2. Given N =19, the function should return 199(the sum of digits is 1+9+9=19).
3. Given N =7, the function should return 7.
Assume that:
N is an integer within the range [0..50].
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.

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!