Say I would like to generate a pseudo-random number, which only contains the digits 1, 4, 7 (this is arbitrary).
My first guess would be to create and array "147" and create random numbers in the range [0..2] and use these numbers as an index into this array to concatenate a number in a loop.
I wonder if there is a more "mathematics"-like answer?