+ 21

# 🌟🌟CHALLENGE: SUM OF SUB-NUMBERS🏆🌟🌟

(level : easy) Find the number whose sum of its sub-numbers gives the initial (input) number. The sub-numbers of result number are obtained as follows: 1. first sub-number is equal to the first digit of result number, 2. second sub-number = on previous sub-number we add the following digit. 3. and so on to the end of all digits. For example: Input: 5684 Output: 5117 Proof: 5 + 51 + 511 + 5117 = 5684 Note: if it is impossible to find the result, output is like: Impossible! Any language is welcome!

3rd Nov 2017, 10:54 AM
LukArToDo
11 odpowiedzi
7th Nov 2017, 5:12 PM
John Wells
+ 20
This is my solution for example : https://code.sololearn.com/WdqXuUUX81Xq/?ref=app
3rd Nov 2017, 10:57 AM
LukArToDo
4th Nov 2017, 12:53 PM
David Akhihiero
+ 8
This is my answer in Java: To see an impossible case, enter 232. Another impossible case is 999995! To see an interesting case enter 1234567. My code also works for 0 or 1-digit numbers! https://code.sololearn.com/cH9Ftw1hHRYo
3rd Nov 2017, 9:54 PM
Vahid Shirbisheh
+ 5
3rd Nov 2017, 2:28 PM
sayan chandra
4th Nov 2017, 4:12 AM
Stephanie
+ 3
not yet ready, but there are some rules: output<input but not more than 999 + 99 +9
4th Nov 2017, 6:59 AM
Oma Falk
4th Nov 2017, 7:27 AM
Bill Fisher
+ 3
My solution works like this: a 'TestNumber' method sums the sub-numbers separately from zero until that sum is greater than the initial number in which case it returns false, otherwise it means that a solution was found and returns true. See it pls. ☺😊😀😁 https://code.sololearn.com/cROBDWzK3Agw/?ref=app
4th Nov 2017, 9:30 PM
Marfik Em
5th Nov 2017, 3:40 AM
Hiroki Masuda
4th Nov 2017, 9:50 AM
VcC