Find least numerator and denominator for a given sequence of numbers in decimal form

46 Views Asked by At

Say I have a sequence (s) of digits written as number. (Ex: 1234567890) I need to find out shortest possible pair of numerator (n) and denominator (d) that ,being converted to decimal form of fraction (r), starts with that sequence after a decimal point. What would be the formula for finding n and d through s.

Example: let s=123, the r may be 0.123456, 0.1234444, 2.123456, etc. r = n/d, find a pair of least n and d of all possible r in form ... .123 ...

Thanks!