Problem · Math
Count Ideal Numbers
Learn this problemProblem statement
An ideal number is an integer that can be written as 3^x * 5^y, where x and y are non-negative integers.
Given two integers low and high, count how many ideal numbers are in the inclusive range [low, high].
Function
countIdealNumbers(low: int, high: int) → intExamples
Example 1
low = 1high = 15return = 5The ideal numbers in the range are 1, 3, 5, 9, and 15.
Example 2
low = 16high = 100return = 5The ideal numbers in the range are 25, 27, 45, 75, and 81.
Constraints
lowandhighare positive integers.low <= high