Multiply together every digit of a positive integer and you get a non-negative integer. In base 10 this rule defines a function f. For example, f(38)=3×8=24.
The same rule works in any base. Written in base 3, the number 80 is 2222, so f3(80)=2×2×2×2=16.
Solve the reverse problem. Given a base B and a target N, find the smallest positive integer X with fB(X)=N, where fB(X) is the product of the digits of X written in base B.