Write ALL numbers from 1 to 342 in base 7 as 3 digits, such as the following:
000, 001, 002, 003, 004, 005, 006, 010, 011, 012, 013, 014, 015, 016.........and so on to 666, and 1000. This gives you a total of:
3 x 49 x 7 =1,029 digits in 342 numbers in base 7. Since each number from 0 to 6 is equally present in the above 1029 digits, it, therefore, follows that there are:1,029 / 7 =147 fours and 147 fives, in any combinations of the two.