Sorry, I let this go before finishing editting. If converting to rationals scares you, try this based on James Farey's "Farey fractions. def Farey(v, lim): '''Convert v to a rational with denom <= lim Named after James Farey, an English surveyor. No error checking on args -- v >= 0, lim = max denominator, results are (numerator, denominator) in lowest terms. Think of (1,0) as infinity. ''' lower, upper = (0L,1L), (1L,0L) while 1: mediant = (lower[0] + upper[0]), (lower[1]+upper[1]) if v * mediant[1] > mediant[0]: if lim < mediant[1]: return upper lower = mediant else: if lim < mediant[1]: return lower upper = mediant
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4