+ 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
LukArToDo - avatar
11 Answers
7th Nov 2017, 5:12 PM
John Wells
John Wells - avatar
+ 20
This is my solution for example : https://code.sololearn.com/WdqXuUUX81Xq/?ref=app
3rd Nov 2017, 10:57 AM
LukArToDo
LukArToDo - avatar
4th Nov 2017, 12:53 PM
David Akhihiero
David Akhihiero - avatar
+ 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
Vahid Shirbisheh - avatar
+ 5
3rd Nov 2017, 2:28 PM
sayan chandra
sayan chandra - avatar
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
Oma Falk - avatar
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
Marfik Em - avatar
5th Nov 2017, 3:40 AM
Hiroki Masuda
Hiroki Masuda - avatar
4th Nov 2017, 9:50 AM
VcC
VcC - avatar