How many time the digit 6 appear when we count from 6(base 8) to 400 (base 8)? How many time the digit 6 appear when we count from 6(base 8) to 400 (base 8)?
I am not sure if I am going in the right path. I want to find the most accurate approach of solving this problem.
6(base 8)=6(base 10). Also, 400(base 8)= 256 (base 10). Now, zero will come in base 8 system if we encounter 10 somehow. So, 8(base 10) will yield 10(base 8). Now, in the units place next 6 will come at 16 (base 8) which is eight places away from 6. So, 6 will come in the units place in gaps of 8. So, total number of 6's in units place = int(((256-6)+1)/8)+1=32. Similarly, for tens place 6 will come 8 times per 64(base 10) numbers. Therefore, total 6's in tens place=256/64*8=32. We ignore the effect of first 5 numbers and take the whole as 256 because it does not matter if I take the first 5 into account or not. It does not contain any 6. Now total number of 6s=32+32=64. Is this answer ok? I don't know the correct answer. Please help on the approach.

It's easier to do everything in base $8$ until the very end. We'll process each digit separatedly.
$6$ appears as the last digit in $6,16,26,\ldots, 376$, so there are $40$ of them.
$6$ appears as the second last digit in $60,61,\ldots,67;160,161,\ldots,167;\ldots; 360,361,\ldots,367$, so there are $10\cdot4=40$ occurrences.
Everything is accounted for, so there are $40+40=100$ occurrences in total in base $8$, which is $64$ occurrences in base $10$.
