"In mathematics, the Farey sequence of order n is the sequence of completely reduced fractions, either between 0 and 1, or without this restriction,[a] which when in lowest terms have denominators less than or equal to n, arranged in order of increasing size.
With the restricted definition, each Farey sequence starts with the value 0, denoted by the fraction 0/1, and ends with the value 1, denoted by the fraction 1/1 (although some authors omit these terms)."
Farey is very simple to use to get the desired fration.
let result = Farey.get(number: 0.456)- returns the desired fraction as a
Fractionobject.
- returns the desired fraction as a