Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions