# Revision history [back]

You can't in general, without making some further assumptions -- how do you know that the answer really isn't 33333/100000?

If you want a sort of best-guess fraction, you can use the Farey sequence and the Sage function farey

sage: farey(0.3333, 1)
(0, 1)
sage: farey(0.3333, 2)
(0, 1)
sage: farey(0.3333, 3)
(1, 3)
sage: farey(0.3333, 100)
(1, 3)


You can't in general, without making some further assumptions -- how do you know that the answer really isn't 33333/100000?

If you want a sort of best-guess fraction, you can use the Farey sequence and the Sage function farey:

sage: farey(0.3333, 1)
(0, 1)
sage: farey(0.3333, 2)
(0, 1)
sage: farey(0.3333, 3)
(1, 3)
sage: farey(0.3333, 100)
(1, 3)