OFFSET
0,2
COMMENTS
a(n) is the denominator of the smallest nonnegative fraction r such that round(10^d*r) = n, where d is the number of digits of n and Gaussian rounding (round half to even) is applied.
EXAMPLE
The table below shows the different rational numbers which satisfy the requirements of the definition except minimality. The denominators of the first rational number in each row constitute the sequence. Note that the round function is not implemented uniformly in popular software. For example, Mathematica matches our definition, while Maple's round function would return incorrect values.
.
n | rational numbers decimal value rounded(10*r)
----+---------------------------------------------------
0 | 0/1, .0000000000, 0
1 | 1/10, 1/9, 1/8, 1/7, .1000000000, 1
2 | 1/6, 1/5, 2/9, 1/4, .1666666667, 2
3 | 2/7, 3/10, 1/3, .2857142857, 3
4 | 3/8, 2/5, 3/7, 4/9, .3750000000, 4
5 | 1/2, .5000000000, 5
6 | 5/9, 4/7, 3/5, 5/8, .5555555556, 6
7 | 2/3, 7/10, 5/7, .6666666667, 7
8 | 3/4, 7/9, 4/5, 5/6, .7500000000, 8
9 | 6/7, 7/8, 8/9, 9/10, .8571428571, 9
MAPLE
r := proc(n) local nint, k, p, q, S; k := 10^(ilog10(n)+1);
nint := m -> floor(m + 1/2) + ceil((2*m-1)/4) - floor((2*m-1)/4) - 1;
if n = 0 then return 0/1 fi; S := NULL;
for p from 1 to k do for q from p+1 to k do
if nint(p*k/q) = n then S := S, p/q fi
od od; sort(convert({S}, list))[1] end:
a := n -> denom(r(n)): seq(a(n), n=0..68);
CROSSREFS
KEYWORD
nonn,frac
AUTHOR
Peter Luschny, May 20 2018
STATUS
approved