Optimize this

I faced a question today while giving test for a company, you are given two integers l and r and you have to find no of integers between l and r which are of the form 3^x*5^y,that is the only prime factors of the number are 3 and 5,suggest me some optimised approaches to solve this problem.

5^14 and 3^20 are max numbers in integer (2^32) range so you just have 14*20 numbers to check nearly constant. How much more optimization do you need?
Was the test on campus or off campus?

1 Like

can u code your logic?

(including 3^0 * 5^0 )

how you came to know that 5^14 and 3^20 are the max numbers ,did u check on the calculator?

5^15=30517578125 this is also under 32 bit,there is no overflow