Gears
InterviewTime limit1sMemory limit1024 MB
Count how many distinct fractions a/b exist with both a and b in the range M to N.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Combinatorics, Brute force
- Solved
- No attempts yet
Problem
A watchmaker owns a lathe that can make gears with anywhere from to teeth.
Write a program that determines how many different gear ratios (transmissions built from two gears) can be produced on this machine. Two gear ratios are counted as different when their value — the number of teeth on the first gear divided by the number of teeth on the second gear — is different.
Input
The first line contains two space-separated integers and (), the minimum and maximum number of teeth on the gears that this machine can make.
Output
Print the number of different gear ratios that can be produced, on a single line.