[Question]
  [
[Negadecimal](https://en.wikipedia.org/wiki/Negative_base), also known as base -10, is a non-standard positional numeral system.
Take the number \$1337\_{10}\$. In decimal, this has the value one thousand three hundred thirty seven, and can be expanded to:
$$1\cdot10^3+3\cdot10^2+3\cdot10^1+7\cdot10^0$$
$$(1000)+(300)+(30)+(7)$$
In negadecimal, instead of \$10^n\$, each digit would be multiplied by \$(-10)^n\$:
$$1\cdot(-10)^3+3\cdot(-10)^2+3\cdot(-10)^1+7\cdot(-10)^0$$
$$(-1000)+(300)+(-30)+(7)$$
Thus, \$1337\_{-10}\$ is \$-723\_{10}\$ in decimal. (An interesting consequence of this is that negative signs are unnecessary in negadecimal; any integer can be represented as `/[0-9]+/`.)
In this challenge, your score is the sum of the lengths of two programs or functions:
* One to convert a number in negadecimal to decimal
* One to convert a number in decimal to negadecimal
All inputs will be integers. You must be able to handle negative numbers. You can take input and output in any reasonable way. This is code golf, so the shortest answer in bytes per language wins.
## Test cases
**Negadecimal to decimal:**
```
1337   -> -723
0      -> 0
30     -> -30
101    -> 101
12345  -> 8265
```
**Decimal to negadecimal:**
```
-723   -> 1337
0      -> 0
1      -> 1
21     -> 181
-300   -> 1700
1000   -> 19000
-38493 -> 179507
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
## Nega to Deca
```
T(ö
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/ROPwtv//DY2NzQE "05AB1E – Try It Online")
## Deca to Nega
```
T(в
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/ROPCpv//dc2NjAE "05AB1E – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 59 bytes
```
f=(p,e=n=>n&&(i=(n%10+10)%10)-p*e((n-i)/p))=>e
f(10)
f(-10)
```
[Try it online!](https://tio.run/##dc9NDoIwEAXgPafoRjJVK1OqKSzKXQiWH0NKI8br1xKEYIndTJMv8/LmUb7LsXp29sXMcNfO1QrsWSujChPH0CkwB44njtQPyuxRAxjW0cRSqgodNaoGD1HrJ/MfVw1mHHp96YcGGuBCSEIoJUlCmExFFDCZ3sw8tIyvlu5QIq65AjHkHL1/c3HPMr@hXLaza/7bq4Wp6trLnxDw/9otpHxjWahT11VlUMwH44Zz3PlcdlmfjnAf "JavaScript (Node.js) – Try It Online") `f` defines a helper function. `f(10)` returns a function that converts from negadecimal to decimal while `f(-10)` returns a function that converts from decimal to negadecimal.
[Answer]
# JavaScript (ES6), 25 + 55 = 80 bytes
## Negadecimal to decimal (25 bytes)
```
f=n=>n&&n%10-10*f(n/10|0)
```
[Try it online!](https://tio.run/##XclBCoMwEEDRvafIRkmEmJmMVjf2LmJNUWQitXTl3aMgFcxffXhT9@vW/jMuX83@NYTgWm6fnGWcImiE3Ek2CBuo0Hte/TwUs39LJ5GoFkoJY4SuLSV3BXF0KkREcJGmGBHwj8fGaKmsTmzsowo7 "JavaScript (Node.js) – Try It Online")
### How?
This one is pretty straightforward. We recursively compute:
$$f(n) = \cases{
0, n=0\\
(n \bmod 10) - 10\times f\left(\left\lfloor\dfrac{n}{10}\right\rfloor\right), n>0}$$
## Decimal to negadecimal (55 bytes)
```
f=(n,i=n%10,k=n>0?-n:~n-i+(i+=10))=>n?f(k/10|0)+i%10:''
```
[Try it online!](https://tio.run/##ZczRDoIgGAXg@56CmyZMiR@pIW7osziTRrqflq2r1qtTbdWMzu13zjl2127uz/504Rj2Q4zOUiy8xbWEYrTYQMuxviP3OfW5lcCYbbB1dBQSbsBy/yzWWRb7gHOYhs0UDtRRrktFCGNECCKV0qtfluSVNydWyoVVqXIF8FUNkB7Dgg38OVfV1qjP3OxAxwc "JavaScript (Node.js) – Try It Online")
### How?
In JS, the result of the `%` operator has the same sign as the dividend. For instance, `-17 % 10` is `-7` rather than `3` (like in Python), which is what we'd really like to get here. A possible workaround would be:
```
(n % 10 + 10) % 10
```
Besides, we also need to compute \$\left\lfloor n/-10\right\rfloor\$ with \$n\$ either positive or negative. This can be done with:
```
Math.floor(n / -10)
```
but this expression is a bit lengthy.
Rather than dealing with both issues separately, we explicitly test the sign of \$n\$ and compute the variables `i` and `k` accordingly:
* We unconditionally set `i = n % 10`.
* If \$n>0\$, we define `k = -n` and leave `i` unchanged.
* If \$n\le 0\$, we define `k = ~n + 10` and add \$10\$ to `i`. Both operations are merged into `k = ~n - i + (i += 10)`.
We then can use `k / 10 | 0` and `i % 10` in both cases.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
Negadecimal to decimal:
```
ḅ-10
```
[Try it online!](https://tio.run/##y0rNyan8///hjlZdQ4P/LofbHzWt@f8/movT0NjYXEdBQVlB105B19zIkovTAMhVgIoYcHEaQ/gQBcZAAUMDQx2YAJANFDAyNjHVgQhYGJmZcsUCAA "Jelly – Try It Online")
Decimal to negadecimal
```
b-10
```
[Try it online!](https://tio.run/##y0rNyan8/z9J19Dg/@H2R01rHu7o@f8/motT19zIUkdBQUFZQddOwdDY2JyL0xDEhwtxcRpBBSB8C6CIrrGBAUKTuYEBUJMBspClAUhM19jCxNJYB6bM0tTAnCsWAA "Jelly – Try It Online")
Input as an integer, output as a list of digits. +2 total bytes (+1 to each) to I/O as integers
[Answer]
# [Lisp Flavored Erlang](https://lfe.io/), 33 + 59 + 59 = ~~153~~ 151 bytes
```
(defun m(X Y)(rem(+(rem X Y)Y)Y))
(defun n(N)(if(== N 0)0(-(m N 10)(*(n(floor(/ N 10)))10))))
(defun d(N)(if(== N 0)0(+(m N 10)(*(d(ceil(/ N -10)))10))))
```
`n` computes the decimal, given a negadecimal. `d` computes the reverse.
Both functions take & return a regular integer.
Erlang's `rem` function works like JavaScript's instead of like Python's, which is why the `m` function is necessary. I save some total bytes by reusing it — if this were 2 separate challenges, it would be inlined as each function only uses it once.
Edit: Rearranged some of the function calls to save a couple bytes without changing logic
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~17~~ 13+35 = 48 bytes
From negadecimal:
```
Fold[#2-10#&]
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73y0/JyVa2UjX0EBZLfZ/QFFmXkm0sq5dWrRbUX6uS2Z6ZkmxvoNzRmJRYnJJalGxg3JsrFpdcHJiXl01l5KhsbG5kg6XkgGIMAaThgaGYMrI2MRUiav2PwA "Wolfram Language (Mathematica) – Try It Online")
Input a list of digits.
To negadecimal:
```
f@0=0
f@a_:=f@-⌊a/10⌋||a~Mod~10
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78/z/NwcDWgCvNITHeyjbNQfdRT1eivqHBo57umprEOt/8lDpDg/8BRZl5JdHKunZpDsqxanXByYl5ddVcuuZGxjpcBjpchjpcRkCsa2wA4hiASF1jCxNLY67a/wA "Wolfram Language (Mathematica) – Try It Online")
Return an `Or` of digits, including a leading zero.
+1 byte to output as an integer instead: [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z/NwcDWgCvNITHeytbQIM1B91FPV6K@ocGjnm7txDrf/JQ6Q4P/AUWZeSXRyrp2aQ7KsWp1wcmJeXXVXLrmRsY6XAY6XIY6XEZArGtsAOIYgEhdYwsTS2Ou2v8A "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 28 + 59 = 87 bytes
### Negadecimal to decimal
```
[ 0 [ swap 10 * - ] reduce ]
```
[Try it online!](https://tio.run/##PY2xCsIwGIT3PMW5CkpjFaE@gHTpIk6lQ4i/tNimMfmDSOmzx1BUbrjv44a7K82ji9dLWZ0LPMgZ6jEobmEdMb@t6wzD0zOQ0eRxEmVVwGunWLdCrMDkGZ2xgb2YBDBBIk85Yl4s@3b@J5lI/nmXlj0OyedYp6WGfykLmWGNDRo4ugVNaOKg7O9uDLz8baF7Ui5@AA "Factor – Try It Online")
Takes an array of negadecimal digits and returns an integer.
```
[
  0 [ ... ] reduce   ! Reduce over the digits with starting value of 0...
    swap 10 * -      ! ( accum digit -- accum' ) Evaluate accum * -10 + digit
]
```
### Decimal to negadecimal
```
[ [ dup 0 = not ] [ -10 2dup / ceiling -rot rem ] produce ]
```
[Try it online!](https://tio.run/##NY5Pi8IwFMTv/RTjB0hN2wX/LHtevHhZPJUeQnxqsE2yLy8LIn72bhS8DMz8BmZOxkrg@fCz239vcSX2NGIycnlJfcreigs@ITKJ3CI7L0j0m8lbSvisdvstkmUj9lJVCwglgfMxS6ruUKu2Q4O2geq0RqOLqG79senwmHv0OOYIjS/4IBiKV41G@wyXsORG589QXBjTVHjkcMyWMMyTie@xkOW11pfSH3EquHyPqGFHMjz/Aw "Factor – Try It Online")
Takes an integer and returns an array of negadecimal digits in reverse order. Does not produce any leading zeros, which means the input of 0 gives an empty array.
```
[
  [ cond ] [ loop ] produce   ! Starting with the value of n, loop until cond gives false
                              ! and collect the top values during the loop
    dup 0 = not               !   Cond: stop if top is 0
                              !   Loop: yield the last digit and keep the higher value
    -10 2dup / ceiling        !   ( n -- n -10 keep ) keep = ceil(n/-10)
    -rot rem                  !   ( keep yield ) yield = n%-10 (non-negative mod)
]
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
## Negadecimal to decimal, 4 bytes
```
B_10
```
[Try it online!](https://tio.run/##yygtzv7/3yne0OD////RhjrGQGgeCwA "Husk – Try It Online")
input as list of digits, output as integer.
## Decimal to Negadecimal, 4 bytes
```
B_10
```
[Try it online!](https://tio.run/##yygtzv7/3yne0OD///@65kbGAA "Husk – Try It Online")
input as integer, output as list of digits.
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 40 bytes
## Negadecimal to decimal, 10 bytes
```
{y+x*-10}/
```
[Try it online!](https://tio.run/##y9bNz/7/P82qulK7QkvX0KBW/3@auoahgjEQmlsraOgYaFoDmQoG1gqGCgYKhiDKCChgomCq@R8A "K (oK) – Try It Online")
## Decimal to negadecimal, 30 bytes
-8 bytes thanks to coltim!
```
{$[~x;0;(10*o@-_-x%-10)+10!x]}
```
[Try it online!](https://tio.run/##y9bNz/7/P82qWiW6rsLawFrD0EAr30E3XrdCVdfQQFPb0ECxIrb2f5q6hq65kbGCoYKRoYKusYGBgqEBkNA1tjCxNFYw0FT4DwA "K (oK) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 31 + 34 = 65 bytes
## Negadecimal to decimal, ~~32~~ 31 bytes
Saved a byte thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor)!!!
```
f=lambda n:n and~9*f(n/10)+n%10
```
[Try it online!](https://tio.run/##TY7dCoJAEIXvfYpBCN0aaX8yU7Cb6CmyC9MVpVpF98JuevVttR8amOF8h@FwuoeuW8WNqdJbfr@UOahEQa7KZ7ysfLVmlKzUglGj5aAHSMF3wI7PhIgQgogLgm@HItCvFhYC8UNGGYI9P@ZiEyLs@Da0FnGKWhZX2U/pbjYeeTbGB7uhi/DPwiVO1fagUUKjYG6UzIlTscrXZIaub5S2T@AFew9hQPjkn2SaDmfzAg "Python 2 – Try It Online")
## Decimal to negadecimal, ~~42~~ ~~35~~ 34 bytes
Saved 7 bytes thanks to [att](https://codegolf.stackexchange.com/users/81203/att)!!!  
Saved another byte thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor)!!!
```
g=lambda n:n and n%10+10*g(0-n/10)
```
[Try it online!](https://tio.run/##TU7LDoIwELzzFRsSQ6tt3FINYIIX41eIB8SKRi2E9qBfXwv42mSTnZndmW2f9tzo2Lk6v5X3w7EEvdJQ6iPoicCZwGlNkOu5QOqsMtYIyIEE4IvwJJYMhJQJZSMjPPzMyAA/c9wL6VfiEr0qEvwuCByYDH8Ul@ki6/2TbIl9Ag2qs6ququs/CIvHNi4e2cb3MmTwj2VIg1PTgWUKLhrGt1eDq/G3NbF0AG130dZvQcTXEQPD4B2wU3lu9u4F "Python 2 – Try It Online")
[Answer]
# [Racket](https://racket-lang.org/), 106 bytes
## Negadecimal to decimal, 39 bytes
```
(λ(x)(foldl(λ(a b)(+(* -10 b)a))0 x))
```
[Try it online!](https://tio.run/##HYtRCsIwGIPfe4qADyaK0DrF8/y6TsRaZexhd/MOXqn@GyHkCyGj3Z55apti9Y5xLYF9Hh41ozb@vpzF4V36srDhKu65wyFFR5MiZqkpBL7sg4otmdC5LgKjuwOWSIhIax59POEsv/0B "Racket – Try It Online")
Takes an array of negadecimal digits and returns an integer.
## Decimal to negadecimal, 67 bytes
```
(define(d x)(if(= 0 x)0(+(modulo x 10)(*(d(ceiling(/ x -10)))10))))
```
[Try it online!](https://tio.run/##JYxbCsIwFES3MuCHc5Vg0gjqh4sJTVqC6YOqUNfmHtxSvdWfYebAnCnUt/RYNiX0Lab/YExN7hMjZmFueIXVZrlnN8RnGTDDWeGOkXXKJfctD8qMQpFfiDryfSzhBXZhBD9vqmsVCrY0p8rDoXIw3lqVaRh/Pl481vfyBQ "Racket – Try It Online")
Takes the input as an integer and returns an integer.
[Answer]
# Scala, 15 + 71 = 86 bytes
### Negadecimal to decimal
```
_.:\(0)(_-10*_)
```
[Try them both online!](https://scastie.scala-lang.org/fUFog85tSwibyflcYkBnpA)
Takes input as a reversed list of digits.
This is rather straightforward - multiply the first digit by -10, add the second digit to that, multiply that by -10, and so on.
### Decimal to negadecimal
```
Seq.unfold(_){x=>val m=(x%10+10)%10;Option.when(x*x>0)(m->(m-x)/10)}:+0
```
Returns a reversed list of digits, with a leading zero (at the end).
This is not so trivial. Because of the way Scala's `%` works, we can't just use `x%10`, as it maintains the sign of `x` and not `10`. 10 has to be added to `x%10` to ensure it is positive, and then `%10` is done again.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 19 bytes
```
{×₁₀ʰ↔-}ˡ
```
[Try it online!](https://tio.run/##AU8AsP9icmFjaHlsb2cy/3t3IiAtPiAidz/hurnihrDigoLhuol94bWQ/3vDl@KCgeKCgMqw4oaULX3Lof//WzEzMzcsMCwzMCwxMDEsMTIzNDVd "Brachylog – Try It Online")
```
≜{×₁₀ʰ↔-}ˡ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRuX/eobcOjpqaHuzprH26d8P9R55zqw9MfNTU@amo4teFR2xTd2tML//@Pjjc3MtYx1DEy1Ik3NjDQMTQAEvHGFiaWxrEA "Brachylog – Try It Online")
Negadecimal input and output is as digit lists. The decimal to negadecimal program uses reversed I/O and is also impressively slow, as it uses pure brute force (coming out 6 bytes shorter than [a saner implementation](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3w36BG9VFT46OmBl81fQjj4c7WRz2dIHbbBh3f//@j482NjHUMdYwMdeKNDQx0DA2ARLyxhYmlcSwA)).
```
{      }ˡ    Left fold over input negadecimal digits:
 ×           multiply
    ʰ        the accumulator
  ₁₀         by 10,
     ↔-      subtract it from the next digit.
≜             Try outputting all integers until the output
 {×₁₀ʰ↔-}ˡ    is the negadecimal representation of the input.
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 28 + 43 = 71 bytes
## Negadecimal to decimal, 28 bytes
```
f(n){n=n?n%10-10*f(n/10):0;}
```
[Try it online!](https://tio.run/##XZDhToMwFIX/7yluSEiAtVlLnVMR/WF8CiELKWUS9W6hJBIJry7eITCxyb1pT87X9lzND1r3feGh32KMj@hKwaUISNhI4d@JqOs/shI9H9oV0CqxhtrY2u4xzF9SiKGVSu0YCAaKSgpJLVRX2y6aAdOcjK5NPjPQ8l2oBojP1E14PUH6NasC6ka/mer3FSdpnsOkuX2i2joM/p6VM3LFsQLv/GKJuWkIE9G4vQdbfplj4c2f9zejElykCNbrwT/FnRIg3XWJPVjSaOGw5DiPcakaUhfp/6OnimyF57g58Aeg7toEKR4ysGyegIljm45Xd6uu/9bFe3awPf/8AQ "C (gcc) – Try It Online")
## Decimal to negadecimal, ~~48~~ ~~45~~ 43 bytes
Saved 3 bytes thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor)!!!  
Saved 2 bytes thanks to [rtpax](https://codegolf.stackexchange.com/users/85545/rtpax)!!!
```
g(n){n=n?n%~9+10*(g(n/~9+(n=n%~9<0))+n):0;}
```
[Try it online!](https://tio.run/##XVDtaoQwEPx/T7EIQvziEtPDs57tj9KnqFIkRittc4cRKhX76LWrVa82kN3NMDNhR3ilEMNQEmV1Klb3yvwKHUZtgsgeR4IgQidqWY6ybmnUD@9ZpYgF3Q7wVKqBRupGP@e@ekohhs4LfO4Cc4G64GPzOMWJ0bF6/HgT8j5atbK9SNHIfJVDxzgPFj07YmfBZBBODiwIDzSYHcRLVttYpXiV9e/vRtI@@kkbPuA9GC78fXNj1hXnGsj4faVy2aKMRvN4Al19ynNB1qWs/YzYVygCx5n4SwzLOgq9rnFMlDTaMDQyxrS3qER0E8V/6aVGWkEMMwfvDrCaOlG4nnJBu2sCMo51Olv3u374FsVbVurB@/gB "C (gcc) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 71 bytes
*Combined negadec\_to\_dec and dec\_to\_negadec code thanks to [user](https://codegolf.stackexchange.com/users/95792/user), and inspired by [Neil's answer](https://codegolf.stackexchange.com/a/215840/95126)*
```
b=function(p)d=function(x)`if`(x,(y=x%%10)-p*d((x-y)/p),0)
b(10)
b(-10)
```
[Try it online!](https://tio.run/##VY3dCoMwDIXv@x5CMlLWGIfbRZ/Ff4cwtDgH9em7bgrizTkk58vJHEJt@8/YLMM0gsP2GDyWQ1@CJ1itTxI2qN2lBfB6xatDMqhq4L/qaGHsnlXbNcUyFdHslu2LPbMbqtS7cu61QgMskpMhMcSGiVPJbkjnJjxonacSaaaUSYv5HUXRcs8egnT@hSp8AQ "R – Try It Online")
---
# [R](https://www.r-project.org/), ~~49~~ ~~47~~ 41 + 47 = 88 bytes
*Separate functions*
**negadecimal to decimal (~~49~~ ~~47~~ 41 bytes):**
*Edit: -2 bytes (and, as a consequence, -6 more bytes) thanks to [att](https://codegolf.stackexchange.com/users/81203/att)*
```
d=function(x)`if`(x,x%%10-10*d(x%/%10),0)
```
[Try it online!](https://tio.run/##VcxBDkAwEEDRvXs0mZERM0qsnKWaFpFICZXU6cvW6r/VP3OYFusnZ@JuvgzZD/MdXFz3AAnHdR4hUVJKuBIuPSRVf0ZizJc9ju0BB6J1T0yaSVhIGt12SP8vFkV@AQ "R – Try It Online")
**decimal to negadecimal (47 bytes):**
```
d=function(x)`if`(x,(y=x%%10)+10*d((y-x)/10),0)
```
[Try it online!](https://tio.run/##VY3LCoAgEADv/UewWyutGVQHv6VCK4Kw6AH69ea1yzBzmiva2QzPMbh5nZLqaPXyOvNshwOP47aM4AmC9nkuGUvJhQUIwmOVkhjjPZ3nHsCAaGtFTJJqSUJxMk4Qqmt6hfTfYJbFDw "R – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 5 + 18 = 23 bytes
## Negadecimal to decimal:
```
Ｉ↨Ｓ±χ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwymxOFXDM6@gtCS4BCiarqGpo@CXmp5YkqphaKAJBNb//xsaG5v/1y3LAQA "Charcoal – Try It Online") Link is to verbose version of code. This is just custom base conversion with a base of `-10`.
## Decimal to negadecimal:
```
ＮθＰ0Ｗθ«←Ｉ﹪θχ≔±÷θχθ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/98zr6C0xK80Nym1SKNQ05rLtzSnJLOgKDOvREPJQAkoUJ6RmZOqAJRTqObiDABLWPmkppXoKDgnFpdo@OanlObkaxTqKBgaaGoC1XM6Fhdnpudp@KWmJ5akanjmlbhklmWmpMKU6CiArKn9/1/X3Mj4v25ZDgA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｎθ
```
Input the decimal number.
```
Ｐ0
```
Print a `0` in case the input is zero.
```
Ｗθ«
```
Repeat until the input is zero.
```
←Ｉ﹪θχ
```
Print the next digit in right-to-left order.
```
≔±÷θχθ
```
Divide the input by `10` and change its sign. (Sadly this is not the same thing as dividing the input by `-10`.
[Answer]
# [Ruby 2.7](https://www.ruby-lang.org/), ~~69~~ ~~68~~ 66 bytes
---
# ~~24~~ 23 bytes
*-1 byte thanks to [Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler)*
```
->x{x.reduce{_2-_1*10}}
```
[Try it online!](https://tio.run/##Tc1BCoNADAXQfU/xoTvJSDKj1U29iLix1bUMKBbHs0@VqJjs/ssnfmx/sX9HU83LnPruO366JXiawmR8IryucUBfoxZy2xYNGgBPwFQwhXUPVdZcR5UPcnTDo@hOFGKSkxWF5UK7vcwo3w8US/vK4x8 "Ruby – Try It Online")
TIO uses an older version of Ruby, while in Ruby 2.7, we've numbered parameters, which saves 3 bytes.
---
# ~~45~~ 43 bytes
```
f=->x,s=''{x!=0?f[-~~(x/10),"#{x%10}"+s]:s}
```
[Try it online!](https://tio.run/##KypNqvz/P81W165Cp9hWXb26QtHWwD4tWreuTqNC39BAU0dJubpC1dCgVkm7ONaquPZ/gQJQ1tzIOFZBQUFZwdDY2JwLJGQI4kOEwHwjqACQbwER0TU2MIBqMjcwgGgygAtZGkDFdI0tTCyBpoOUWZoamP8HAA "Ruby – Try It Online")
]