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].
Examples
01 · Example 1
low = 1 high = 15 return = 5
The ideal numbers in the range are 1, 3, 5, 9, and 15.
02 · Example 2
low = 16 high = 100 return = 5
The ideal numbers in the range are 25, 27, 45, 75, and 81.
Constraints
lowandhighare positive integers.low <= high
More IBM problems
- Count Descending SubarraysOA · Seen Apr 2026
- Count Power Products in RangeOA · Seen Apr 2026
- Minimum Operations to Make Alternating Binary StringSeen Feb 2026
- Minimum Number of Non-Empty Disjoint SegmentsSeen Feb 2026
- Count Unstable ProcessesOA · Seen Feb 2026
- Longest Balanced Binary SubarrayOA · Seen Feb 2026
- Process Execution TimeOA · Seen Nov 2025
- Service Timeout DetectionOA · Seen Nov 2025
public int countIdealNumbers(int low, int high) {
// write your code here
}low1
high15
expected5
sign in to submit