Closed form for number of integers in a rational interval

98 Views Asked by At

Inspired by this question (which is hardly relevant here) I'm curious to know whether there is a closed form for the number of integers in a half-open rational interval $(\tfrac{a}{b},\tfrac{c}{d}]$ where $a,b,c,d\in\Bbb{Z}$ and $b,d\neq0$. It is either $\lfloor\tfrac{c}{d}-\tfrac{a}{b}\rfloor$ or $\lfloor\tfrac{c}{d}-\tfrac{a}{b}\rfloor+1$, but is there a general closed form? That is, is there a well-behaved description of the function $$f:\ \Bbb{Z}\times(\Bbb{Z}-\{0\})\times\Bbb{Z}\times(\Bbb{Z}-\{0\}) \longrightarrow\ \Bbb{N}: (a,b,c,d)\ \longmapsto\ \left|(\tfrac{a}{b},\tfrac{c}{d}]\cap\Bbb{Z}\right|,$$ preferably in terms of elementary functions, gcd's, lcm's, maxima, minima, and the likes.

1

There are 1 best solutions below

0
On

Sure. The number of integers in the interval $(x,y]$ (where $x\le y$) is $\lfloor y\rfloor -\lfloor x\rfloor$.