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-2 of 2 results.

A366928 a(n) is the smallest nonnegative k such that A301573(k) = n.

Original entry on oeis.org

1, 0, 6, 12, 20, 41, 42, 56, 72, 90, 110, 155, 156, 182, 270, 271, 272, 306, 379, 380, 420, 462, 551, 552, 600, 650, 702, 756, 812, 870, 930, 1055, 1056, 1122, 1190, 1260, 1405, 1406, 1482, 1560, 1640, 1805, 1806, 1892, 1980, 2254, 2255, 2256, 2352, 2450, 2550, 2652, 2861, 2862, 2970
Offset: 0

Views

Author

Dmitry Kamenetsky, Oct 28 2023

Keywords

Comments

If negative values were allowed then one could argue a(n) = 1-n from the name of A301573. - David A. Corneth, Nov 13 2023

Examples

			a(3) = 12 as 12 is the smallest positive integer that is 3 away from the closest perfect power (namely 9 = 3^2). - _David A. Corneth_, Nov 12 2023
		

Crossrefs

Programs

  • PARI
    ispp(n) = {ispower(n) || n==1}; \\ A001597
    f(n) = my(k=0); while(!ispp(n+k) && !ispp(n-k), k++); k; \\ A301573
    a(n) = my(k=0); while (f(k) != n, k++); k; \\ Michel Marcus, Oct 29 2023
    
  • PARI
    \\ See PARI link
    
  • Python
    from itertools import count
    from sympy import perfect_power
    def A366928(n): return next(m for m in count(0) if next(k for k in count(0) if perfect_power(m+k) or perfect_power(m-k) or m-k==1 or m+k==1) == n) # Chai Wah Wu, Nov 12 2023

Formula

a(n) > n^2 for n > 1. - David A. Corneth, Nov 13 2023

Extensions

More terms from Michel Marcus, Oct 29 2023

A322522 a(n) is the minimal absolute difference between n and each of the powers of the previous terms; a(1) = 1.

Original entry on oeis.org

1, 1, 2, 0, 1, 2, 1, 0, 1, 2, 3, 3, 3, 2, 1, 0, 1, 2, 3, 4, 5, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1
Offset: 1

Views

Author

Gabin Kolly, Aug 28 2019

Keywords

Comments

a(n) <= ceiling(sqrt(n)); if n is between k^2 and (k+1)^2, we have min(n - k^2, (k+1)^2 - n) <= k < ceiling(sqrt(n)).
Using the fact that the density of the nontrivial powers over the integers is 0, and that the density of cubes and higher powers among the nontrivial powers is 0, we can show that there are an infinite number of integers i such that i is not a nontrivial power, and there is no cube or higher power between (i-1)^2 and i^2. We then have a((i-1)^2 + i) = i = ceiling(sqrt((i-1)^2 + i)). Therefore there are infinitely many numbers n such that a(n) = ceiling(sqrt(n)).
a(n) - a(n-1) <= 1.
For the first 10000 terms, indices for a(n) = 1 correspond to 85 of 90 values of A227802(m). - Bill McEachen, Feb 26 2024

Examples

			For n = 4, we have a(4) = 0, because a(3) = 2, and 2^2 - 4 = 0.
For n = 6, we have a(6) = 0, because there are only 0, 1 and 2 in the first 5 terms, and therefore the closest power is 2^2 = 4 or 2^3 = 8, with an absolute difference of 2.
		

Crossrefs

Cf. A301573 (distance from n to the nearest nontrivial power).

Programs

  • Mathematica
    comparePowers[n_, m_] :=
    If[n <= 1, m - n, a = n; While[a < m, a *= n];
      Min[m - a/n, a - m]]; list = {1}; cleanList = {1}; Do[
    list = Append[list,
       Min[comparePowers[#, Length[list] + 1] & /@ cleanList]];
    If[Last[list] > Last[cleanList],
      cleanList = Append[cleanList, Last[list]]], 9999]; Print[list]

Formula

Let b(n) be the first time that n appears in the sequence; then b(n) ~ n^2.
Showing 1-2 of 2 results.