sudhir3127 wrote:My answer is 14.
here it goes..
30/3 + 30/3^2 + 30/3^3
10 + 3 + 1 = 14
let me know the OA,
Nice, but I think some didn't quite understand it
What sudhir did:
-count how many multiples of 3 there are between 1 and 30- there are 30/3, or
ten multiples of 3.
-we need to count an extra 3 for the multiples of 3^2. How many of these are there? 30/9 = 3+remainder; there will be
three multiples of 3^2.
-finally, we need to count yet another 3 for the multiples of 3^3. How many of these are there? 30/27 = 1+remainder; there will be only
one multiple of 3^3.
10+3+1 = 14.
The approach does depend on the fact that the range of numbers begins from 1; with a different set of numbers, the calculations would be more awkward (in a range of 30 numbers, you can have one multiple of 3^3, or you can have two multiples of 3^3).
It's an elegant approach- nicely done, sudhir.