Answer 2 N where N is the number of digits.
This is a purely mathematical problem and relates to the most basic combinatorics. It is easy to see why 2 N is the correct answer. Indeed, there are two ways to select the first digit. For each such choice, there are two ways to select the second digit. Therefore, there are 2 × 2 ways to choose a two-digit number. For each such number, there are two ways to add a third digit, making 2 × 2 × 2 ways of constructing a three-digit number. Consequently, there are
2 × 2 × ... × 2 = 2^N
ways to build an N-digit number.
In Delphi, you calculate 2 N on Power(2, N) ( uses Math ). [A less naive way that works for N <31, 1 shl N ]
source share