Skip to main content
added 151 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 21 bytes

\(x)x*10^nchar(x)%/%9

Attempt This Online!

Uses an 'x multiplied by 111' approach, where the '111' is constructed as the next power-of-10 greater-or-equal to x, integer-divided by 9.

(now reading the other answers: this is the same approach already used in xnor's Python answer)

R, 21 bytes

\(x)x*10^nchar(x)%/%9

Attempt This Online!

Uses an 'x multiplied by 111' approach, where the '111' is constructed as the next power-of-10 greater-or-equal to x, integer-divided by 9.

R, 21 bytes

\(x)x*10^nchar(x)%/%9

Attempt This Online!

Uses an 'x multiplied by 111' approach, where the '111' is constructed as the next power-of-10 greater-or-equal to x, integer-divided by 9.

(now reading the other answers: this is the same approach already used in xnor's Python answer)

Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 21 bytes

\(x)x*10^nchar(x)%/%9

Attempt This Online!

Uses an 'x multiplied by 111' approach, where the '111' is constructed as the next power-of-10 greater-or-equal to x, integer-divided by 9.