Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Find a fraction with the smallest denominator

Input

Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$.

Output

A fraction with the smallest possible denomination that lies strictly between \$x\$ and \$y\$.

Examples

Input: 1 and 2

Output: 3/2

Input: 0 and 0.33

Output: 1/4

Input: 0.4035 and 0.4036

Output: 23/57

Answer*

Draft saved
Draft discarded
Cancel
1
  • \$\begingroup\$ Which is fortunate since ⌈xd⌉<yd is the wrong test. \$\endgroup\$ Commented Jan 12, 2024 at 23:49

AltStyle によって変換されたページ (->オリジナル) /