05AB1E, 19 bytes
<*I<‰>`ŠmID12‚›P-÷*
Inputs in the order \$f,d,b\$.
Port of @Neil's Charcoal answer, so make sure to upvote him as well!
Try it online or verify all test cases.
Explanation:
Formula: (d*(f-1)%(b-1)+1)*((b**(d*(f-1)//(b-1)+1))//(b-(b>f)*(b>2)))
< # Decrease the first (implicit) input `f` by 1
# STACK: f-1
* # Multiply it to the second (implicit) input `d`
# STACK: d*(f-1)
‰ # Divmod it by
I< # the third input `b` minus 1
# STACK: [d*(f-1)//(b-1), d*(f-1)%(b-1)]
> # Increase both values in the pair by 1 (let's call them [A,B])
# STACK: [d*(f-1)//(b-1)+1, d*(f-1)%(b-1)+1]
` # Pop and push them separated to the stack
# STACK: d*(f-1)//(b-1)+1, d*(f-1)%(b-1)+1
Š # Tripleswap the stack using the implicit third input `b`
# STACK: d*(f-1)%(b-1)+1, b, d*(f-1)//(b-1)+1
m # Take `b` to the power `A`
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1)
I # Push the third input `b` again
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b
D # And again
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b, b
12‚ # Push pair [f,2]
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b, b, [f,2]
› # Pop the copy of `b`, and check [b>f, b>2]
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b, [b>f,b>2]
P # Check if both are truthy by taking the product
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b, (b>f)*(b>2)
- # Decrease the other `b` by this 0 or 1
# STACK: d*(f-1)%(b-1)+1, b**(d*(f-1)//(b-1)+1), b-(b>f)*(b>2)
÷ # Integer-divide `b to the power A` by this
# STACK: d*(f-1)%(b-1)+1, (b**(d*(f-1)//(b-1)+1))//(b-(b>f)*(b>2))
* # Multiply it to `B`
# STACK: (d*(f-1)%(b-1)+1)*((b**(d*(f-1)//(b-1)+1))//(b-(b>f)*(b>2)))
# (after which the result is output implicitly)
Kevin Cruijssen
- 136.2k
- 14
- 154
- 394