n = (0 or 1 or 2) x 30 + (0 or 1 or 2) x 31 + (0 or 1 or 2) x 32In other words
n = (0 or 1 or 2) + (0 or 3 or 6) + (0 or 9 or 18)Thus all number that have a "1" in their makeup will be found in the first square, all number that have a "2" in the second square, a "3" in the third square, a "6" in the fourth square, a "9" in the fifth, and an "18" in the sixth.
The number n can therefore be found by adding the numbers at the top left-hand corner of the squares where n appears.