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
More IBM problems
- String-Pair Frequency SimilarityOA · Seen Jul 2026
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026