cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A303612 a(n) = min{denominator(r) with r in R} and R = {0 <= r rational <= 1 and [r*k] = n}. Here k = 10^(floor(log_10(n))+1) and [x] = floor(x+1/2) + ceiling((2*x-1)/4) - floor((2*x-1)/4) - 1.

Original entry on oeis.org

1, 7, 4, 3, 5, 2, 5, 3, 4, 7, 10, 9, 8, 15, 7, 13, 19, 6, 11, 16, 5, 14, 9, 13, 17, 4, 19, 11, 18, 7, 10, 13, 19, 3, 29, 17, 11, 19, 8, 18, 5, 17, 12, 7, 9, 11, 13, 15, 21, 35, 2, 35, 21, 15, 13, 11, 9, 7, 12, 17, 5, 18, 8, 19, 11, 17, 29, 3, 19, 13, 10
Offset: 0

Views

Author

Luca Petrone, Apr 27 2018

Keywords

Comments

a(n) is the smallest denominator of a fraction that, when rounded to d digits after the decimal point, is equal to 0.n, where d is the number of digits of n, and the rounding convention applied is that a number whose fractional part is 1/2 is rounded to the nearest even integer.
a(k-n) = a(n), where k is the first power of 10 exceeding n.
The sequence [A297367(n)/a(n), n = 10^(k-1)..10^(k)-1] is a subsequence of the Farey sequence A006842/A006843 of order ceiling((2/3)*10^k). For example, the terms a(1)..a(9) are the denominators of {1/7, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 6/7}; this sequence of fractions is a subsequence of the Farey sequence of order ceiling((2/3)*10^1) = 7, i.e., F7 = {0/1, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 2/5, 3/7, 1/2, 4/7, 3/5, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 1/1}.
With the exception of n in {1, 2, 4, 13, 16}, r(n) = A297367(n)/a(n) is in the Farey series of order n (row n of A006842/A006843). - Peter Luschny, May 19 2018

Examples

			The table below shows the different rational numbers which satisfy the requirements of the definition. 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.
.
  |                     |  decimal  |     round(10*r)
n | rational numbers r  |   value   | Mathematica | Maple
--+---------------------+-----------+-------------+------
0 | 0/1                 | 0.0000000 |      0      |   0
1 | 1/7, 1/8, 1/9, 1/10 | 0.1428571 |      1      |   1
2 | 1/4, 1/5, 1/6, 2/9  | 0.2500000 |      2      | * 3 *
3 | 1/3, 2/7, 3/10      | 0.3333333 |      3      |   3
4 | 2/5, 3/7, 3/8, 4/9  | 0.4000000 |      4      |   4
5 | 1/2                 | 0.5000000 |      5      |   5
6 | 3/5, 4/7, 5/8, 5/9  | 0.6000000 |      6      |   6
7 | 2/3, 5/7, 7/10      | 0.6666667 |      7      |   7
8 | 3/4, 4/5, 5/6, 7/9  | 0.7500000 |      8      |   8
9 | 6/7, 7/8, 8/9, 9/10 | 0.8571429 |      9      |   9
		

References

  • C. F. Gauss, Theorematis arithmetici demonstratio nova, Societati regiae scientiarum Gottingensis, Vol. XVI., January 15, 1808, pp. 5-7, section 4-5.
  • L. Graham and Donald E. Knuth and Oren Patashnik, Concrete mathematics: a foundation for computer science (Second Edition), Addison-Wesley Publishing Company, 1994, pp. 86-101.
  • Kenneth E. Iverson, A Programming Language, John Wiley And Sons, Inc., 1962 (4th printing 1967), pp. 11-12.
  • Takeo Kamizawa, Note on the Distance to the Nearest Integer, Faculty of Physics, Astronomy and Informatics, Nicolaus Copernicus University, Toruń, Poland, 2016.
  • A. M. Legendre, Théorie des nombres (deuxième édition), 1808.
  • D. Zuras, M. Cowlishaw, R. M. Grow, et al., IEEE Standard for Floating-Point Arithmetic, Std 754(tm)-2008, ISBN 978-0-7381-5753-5, August 28, 2008, p. 16, sections 4.3.1-4.3.3.

Crossrefs

Programs

  • Maple
    r := proc(n) local nint, k, p, q; k := 10^(ilog10(n)+1);
    nint := m -> floor(m + 1/2) + ceil((2*m-1)/4) - floor((2*m-1)/4) - 1;
    for p from 1 to k do for q from p+1 to k do if nint(p*k/q) = n then return p/q fi od od; 0/1 end:
    a := n -> denom(r(n)): seq(a(n), n=0..99); # Peter Luschny, May 19 2018
  • Mathematica
    a = {1};
    For[i = 1, i <= 100, i++,
    nmax = 10^(Floor[Log[10, i]] + 1);
    r = i/nmax;
    For[n = 1, n <= nmax, n++,
    If[Round[Round[n r]/n, 1/nmax] == r,
    a = Flatten[Append[a, n]];
    Break[];
    ]]]

A239526 For 0<=n<=100, a(n) is the number of positive responses x such that x/N rounds to n%, minimized over sample size N.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 3, 1, 3, 2, 3, 4, 1, 5, 3, 5, 2, 3, 4, 6, 1, 10, 6, 4, 3, 3, 7, 2, 7, 5, 3, 4, 5, 6, 7, 10, 17, 1, 18, 11, 8, 7, 6, 5, 4, 7, 10, 3, 11, 5, 5, 7, 11, 19, 2, 13, 9, 7, 5, 13, 8, 14, 3, 13, 10, 7, 11, 4, 13, 9, 5, 16, 11, 6, 7, 7, 8, 9, 10, 11, 13, 15, 18, 22, 28, 39, 66, 1
Offset: 0

Views

Author

Patrick D McLean, Mar 21 2014

Keywords

Examples

			a(31)=4 because 4/13=0.31 (2DP).
		

Crossrefs

Cf. A239525 (Minimal sample sizes).

Programs

  • Mathematica
    Table[LinearProgramming[{1, 0}, {{-n/100 + 0.005, 1}, {n/100 + 0.005, -1}}, {0, 0}, {1, 1}, Integers], {n, 0, 100}] // Transpose // Last
  • Python
    from itertools import count
    def A239526(n):
        for y in count(1):
            x, z = divmod(y*((n<<1)+1),200)
            if not z: return x
            x, z = divmod(y*((n<<1)-1),200)
            if (x:=x+bool(z)) and (200*x+y)//(y<<1) == n:
                return x # Chai Wah Wu, Jun 28 2025

A384670 Smallest denominator y for which there exists an integer x with round(100*x/y) = n.

Original entry on oeis.org

1, 67, 41, 29, 23, 19, 16, 14, 12, 11, 10, 9, 17, 8, 7, 13, 19, 6, 11, 16, 5, 14, 9, 13, 17, 4, 19, 11, 18, 7, 10, 13, 19, 3, 29, 17, 11, 19, 8, 18, 5, 17, 12, 7, 9, 11, 13, 15, 21, 35, 2, 35, 21, 15, 13, 11, 9, 7, 12, 17, 5, 18, 13, 8, 11, 17, 29, 3, 19, 13, 10, 7, 18, 11, 19, 4, 17, 13, 9, 14, 5, 16, 11, 6, 19, 13, 7, 15, 8, 9, 10, 11, 12, 14, 16, 19, 23, 29, 40, 67, 1
Offset: 0

Views

Author

James Beazley, Jun 06 2025

Keywords

Comments

We allow x=0 so that a(0)=1 is from round(100*0/1) = 0.
If some published statistic shows n percent, and that percentage was made by rounding to the nearest integer (and 0.5 rounds upwards), then it must have been from a sample of at least a(n) things.

Examples

			For n=1, proportion 1/67 = 1.4992...% rounds to n=1 percent and 67 is the smallest denominator allowing that.
		

Crossrefs

Cf. A239525 (round either way).

Programs

  • PARI
    first(n) = {
        res = vector(n, i, oo);
        todo = 100;
        for(i = 1, 100,
            for(j = 1, i,
                c = round(100*j/i);
                if(0 < c && c <= n,
                    if(res[c] == oo,
                        todo--;
                        if(todo == 0,
                            break
                        ));
                        res[c] = min(res[c], i))));
        for(i = 101, n,
            res[i] = res[i-100]);
        concat(1, res)
    } \\ David A. Corneth, Jun 23 2025
    
  • Python
    from itertools import count
    def A384670(n):
        for y in count(1):
            x, z = divmod(y*((n<<1)-1),200)
            if (200*(x+bool(z))+y)//(y<<1) == n:
                return y # Chai Wah Wu, Jun 28 2025
Showing 1-3 of 3 results.