Input:
An integer
Output:
Sum of the input itself + the length of the input + each individual digit of the input.
nr + nr-length + {sum of digits} = output Examples:
Input: 99
Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119
Input: 123
Output: 123 + 3 + (1 + 2 + 3) → 132
Challenge rules:
The input can also contain negative input, which are resolved special. The
-/minus-sign is also+1for the length, and is part of the firstdigit.
For example:Input:
-123
Output:-123 + 4 + (-1 + 2 + 3)→-115- You can assume that the input nor output will ever be outside the range of an (32-bit) integer.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Test cases:
87901 → 87931 123 → 132 99 → 119 5 → 11 1 → 3 0 → 1 -3 → -4 -123 → -115 -900 → -905 -87901 → -87886 Semi-related: Count Sum of all Digits


-123the sum chain should be(-1 + 1 + 2 + 3)instead of(-1 + 2 + 3), right? \$\endgroup\$-1 + 2 + 3. For this challenge I choose to merge the-/minus-sign to the first digit as one negative digit to make it a bit more interesting. \$\endgroup\$