Skip to main content
2 of 7
added 261 characters in body
Uriel
  • 13.2k
  • 4
  • 17
  • 45

Dyalog APL, 13 bytes

{⍺-⍨⍵*⌊1+⍵⍟⍺}

Try it online!

Takes n as left argument and b as right argument.

How?

Written in its math form, this is b⌊logbn + 1⌋ - n.

Uriel
  • 13.2k
  • 4
  • 17
  • 45