26
1
Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6:
The numbers 1 to 6 concatenated:
123456
Reversed:
654321
Adding them up together will result in: 777777. Another example is n = 11:
1 2 3 4 5 6 7 8 9 10 11 > 1234567891011
and
11 10 9 8 7 6 5 4 3 2 1 > 1110987654321
Adding them up together will result in 2345555545332
. This is also known as A078262.
Shortest code wins!
Related. – Zgarb – 2016-02-22T21:21:19.597
Is there a bound to
n
, or do we have to support arbitrarily large integers? – LegionMammal978 – 2016-02-22T22:16:53.057I think the default is "bounded by
max(256,yourlanguagesdefaultintegertypelimit)
". But it should be specified. – CalculatorFeline – 2016-02-22T22:20:34.833@LegionMammal978 As high as your language supports. – Lamaro – 2016-02-22T22:43:33.957
Important test case:
10
, which should give23333333231
. – Adnan – 2016-02-22T23:04:36.960