Further to Robert Israel's post (showing that there are 15 7-digit numbers satisfying the tests), here is a complete count of the numbers that satisfy the tests: Number of Digits Total number 1 9 2 36 3 105 4 165 5 233 6 110 7 15 That makes a grand total of 673 numbers that satisfy the tests. Best, Harvey P. Dale