login
A394354
a(n) = denominator q of the fraction p/q that minimizes |m/n - p/q| with m/n != p/q, where p is 1 or prime, q is prime, q < n, and m ranges from 1 to n - 1, with this rule to ensure uniqueness: if for given n there is more than one minimizing triple (m, p, q), then choose the greatest such m, then greatest q, then greatest p.
5
2, 3, 3, 5, 5, 7, 7, 7, 7, 11, 11, 13, 13, 11, 13, 17, 13, 19, 17, 19, 19, 23, 23, 19, 23, 19, 23, 29, 23, 31, 29, 29, 31, 23, 31, 37, 37, 31, 31, 41, 37, 43, 41, 43, 43, 47, 47, 47, 41, 47, 43, 53, 47, 41, 53, 47, 47, 59, 59, 61, 61, 61, 53, 59, 59, 67, 61, 59, 67, 71, 67, 73, 73, 59, 71, 73, 73, 79
OFFSET
3,1
EXAMPLE
In the following table, columns 1-4 give values for the closest prime-fraction p/q to m/n as determined by the definition of a(n). In particular, a(3)-a(30) occupy column 2. Column 5 shows a comparison: < if p/q < m/n and > is p/q > m/n. Column 6 gives an approximation for the minimal distance |m/n - p/q|.
n m p q comp. min. dist.
3 2 1 2 < 0.16666667
4 3 2 3 < 0.08333333
5 3 2 3 > 0.06666667
6 1 1 5 > 0.03333333
7 4 3 5 > 0.02857143
8 1 1 7 > 0.01785714
9 4 3 7 < 0.01587302
10 7 5 7 > 0.01428571
11 8 5 7 < 0.01298701
12 1 1 11 > 0.00757576
13 6 5 11 < 0.00699301
14 1 1 13 > 0.00549451
15 8 7 13 > 0.00512821
16 3 2 11 < 0.00568182
17 4 3 13 < 0.00452489
18 1 1 17 > 0.00326797
19 16 11 13 > 0.00404858
20 1 1 19 > 0.00263158
21 16 13 17 > 0.00280112
22 15 13 19 > 0.00239234
23 6 5 19 > 0.00228833
24 1 1 23 > 0.00181159
25 12 11 23 < 0.00173913
26 15 11 19 > 0.00202429
27 20 17 23 < 0.00161031
28 25 17 19 > 0.00187970
29 24 19 23 < 0.00149925
30 1 1 29 > 0.00114943
|3/4 - 1/3| = 0.08333333... < |3/4 - p/q| for all other p/q as in the definition of a(n), so a(4) = 3.
MATHEMATICA
u[p_] := p == 1 || PrimeQ[p];
t = Table[min = Infinity;
b = {None, None, None};
Do[Do[If[PrimeQ[q],
Do[If[u[p], If[m/n != p/q, d = Abs[m/n - p/q];
If[d < min, min = d;
b = {m, p, q}; ]]], {p, n, 1, -1}]], {q, n - 1, 2, -1}], {m, n - 1, 1, -1}];
{mVal, pVal, qVal} = b;
comp = If[pVal/qVal < mVal/n, "<", ">"];
{n, mVal, pVal, qVal, comp, NumberForm[N[min], {10, 8}]}, {n, 3, 30}];
TableForm[t, TableHeadings -> {None, {"n", "m", "p", "q", "comp.", "min. dist."}}]
KEYWORD
nonn,frac
AUTHOR
Clark Kimberling, Mar 17 2026
STATUS
approved