Dyalog APL, 13 bytes
{⍺-⍨⍵*⌊1+⍵⍟⍺}
Takes n
as left argument and b
as right argument.
How?
Written in its math form, this is b⌊logbn + 1⌋ - n
.
{⍺-⍨⍵*⌊1+⍵⍟⍺}
Takes n
as left argument and b
as right argument.
How?
Written in its math form, this is b⌊logbn + 1⌋ - n
.