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

A377091 a(0) = 0; thereafter a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference between a(n-1) and a(n) is a square; in case of a tie, preference is given to the positive value.

Original entry on oeis.org

0, 1, 2, -2, -1, 3, 4, 5, -4, -3, 6, 7, 8, -8, -7, -6, -5, -9, -10, -11, -12, 13, 9, 10, 11, 12, -13, -14, -15, -16, -17, -18, 18, 14, 15, 16, 17, -19, -20, -21, -22, -23, -24, 25, 21, 20, 19, 23, 22, 26, 27, 28, 24, -25, -26, -27, -28, -29, -30, -31, -32, 32
Offset: 0

Views

Author

Rémy Sigrist, Oct 16 2024

Keywords

Comments

Conjecture 1: Every integer (positive or negative) appears in this sequence.
Conjecture 2: For n > 16, |a(n)| is within sqrt(n/2) of floor(n/2). See A379071. - N. J. A. Sloane, Dec 29 2024 [Corrected by Paolo Xausa, Jan 21 2025]
Conjecture 3: lim sup ||a(n)| - floor(n/2)|/sqrt(n) = 1/2. (See link.) - N. J. A. Sloane and Paolo Xausa, Feb 03 2025
Conjecture 4: After a(n) has been found, the sequence contains all numbers in the range [0,f(n)], where lim sup f(n) = (n-sqrt(n))/2. There is a corresponding conjecture for the negative terms. See A379067. - N. J. A. Sloane and Paolo Xausa, Feb 13 2025

Examples

			The initial terms are:
  n   a(n)  |a(n)-a(n-1)|
  --  ----  -------------
   0     0  N/A
   1     1  1^2
   2     2  1^2
   3    -2  2^2
   4    -1  1^2
   5     3  2^2
   6     4  1^2
   7     5  1^2
   8    -4  3^2
   9    -3  1^2
  10     6  3^2
  11     7  1^2
  12     8  1^2
  13    -8  4^2
  14    -7  1^2
		

Crossrefs

This sequence is a variant of A277616 allowing negative values.
A large number of sequences have been derived from the present sequence in the hope (so far unfulfilled) of finding a formula or recurrence: see A379057-A379078, A379786-A379798, A379802, A379803, A379804, A379880, A380223, A380224, A380225, A382715-A382718.
First differences are A379061 (certainly the most relevant derived sequence). - M. F. Hasler, Feb 08 2025
"Lexicographically earliest" sequences for which there is a proof that every number that could appear does appear: A064413, A098550, A109812, A121216, A347113, etc. - N. J. A. Sloane, Feb 08 2025

Programs

  • JavaScript
    A377091 = [0]; A377091.least_unused = 1;
    function a(n){
      for(let i = A377091.length-1; i < n; ++i) {
        let k = A377091.least_unused;
        while(!Number.isInteger(Math.sqrt(Math.abs(A377091[i] - k)))
              || A377091.indexOf(k) > 0) k = (k<0)-k;
        A377091.push(k);
        if (k == A377091.least_unused) {
          do k = (k<0)-k; while ( A377091.indexOf( k ) > 0 );
          A377091.least_unused = k;
      } };
      return A377091[n];
    } // M. F. Hasler, Jan 26 2025
  • Maple
    h := proc(b, a, i) option remember; ifelse(issqr(abs(a[-1] - i)) and not is(i in a), ifelse(b < nops(a) + 1, a, h(b, [op(a), i], 1)), h(b, a, ifelse(i < 0, 1 - i, -i))) end:
    a_list := length -> h(length, [0], 1): a_list(62);  # Peter Luschny, Jan 20 2025
  • Mathematica
    A377091list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || !IntegerQ[Sqrt[Abs[# - a]]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0,nmax]];
    A377091list[100] (* Paolo Xausa, Mar 18 2025 *)
  • PARI
    \\ See Links section.
    
  • PARI
    A377091_upto(n,S=[])={vector(n+1, k, S=setunion(S, [n=if(k>1, k=1; while(setsearch(S,k) || !issquare(abs(n-k)), k=(k<0)-k); k)]); n)} \\ M. F. Hasler, Jan 18 2025
    
  • Python
    from math import isqrt
    from itertools import count, islice
    def cond(n): return isqrt(n)**2 == n
    def agen(): # generator of terms
        an, aset, m = 0, {0}, 1
        for n in count(0):
            yield an
            an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s)))
            aset.add(an)
            while m in aset and -m in aset: m += 1
    print(list(islice(agen(), 62))) # Michael S. Branicky, Dec 25 2024
    
  • Python
    from math import sqrt
    def a_list(b: int, a: list[int] = [0], i: int = 1) -> list[int]:
        if sqrt(abs(a[-1] - i)).is_integer() and not (i in a):
            a += [i]
            if b < len(a):
                return a
            else:
                return a_list(b, a)
        else:
            return a_list(b, a, int(i < 0) - i)
    print(a_list(40))  # Peter Luschny, Jan 20 2025
    
  • Python
    class A377091: # A377091(n) gives a(n)
        terms = [0]; N = 1 # next candidate
        def _new_(A, n): A.extend(A, n-len(A.terms)+1); return A.terms[n]
        def extend(A, n): any((k:=A.N) in A.terms and setattr(A, 'N', k:=(k<0)-k) or
            A.terms.append(next(k for _ in range(9**9) if (abs(A.terms[-1]-k)**.5)
           .is_integer() and k not in A.terms or not(k:=(k<0)-k))) for _ in range(n))
    # M. F. Hasler, Feb 08 2025
    

A277618 Lexicographically earliest nonnegative sequence such that |a(n+1)-a(n)| is a prime number, and no number occurs twice; a(0) = 0.

Original entry on oeis.org

0, 2, 4, 1, 3, 5, 7, 9, 6, 8, 10, 12, 14, 11, 13, 15, 17, 19, 16, 18, 20, 22, 24, 21, 23, 25, 27, 29, 26, 28, 30, 32, 34, 31, 33, 35, 37, 39, 36, 38, 40, 42, 44, 41, 43, 45, 47, 49, 46, 48, 50, 52, 54, 51, 53, 55, 57, 59, 56, 58, 60, 62, 64, 61, 63, 65, 67, 69, 66, 68, 70, 72, 74, 71, 73, 75, 77, 79, 76, 78, 80, 82, 84, 81, 83, 85, 87, 89, 86, 88, 90
Offset: 0

Views

Author

Eric Angelini and M. F. Hasler, Oct 23 2016

Keywords

Comments

A variant of A277616, which is defined in a similar way with squares > 1 instead of primes.
The steps a(n+1)-a(n) are either +2 or -3, after 10 terms we get a(n+10), and the first 10 terms are all numbers between 0 and 9: This sequence is obviously a permutation of the nonnegative integers, with a(n) = a(n-5) + 5 for all n > 5. The strictly positive variant (starting with a(1) = 1) is given by A065186.

Crossrefs

Programs

  • Mathematica
    Table[n - 2 + Mod[n - 3, 5], {n, 0, 500}] (* Fred Patrick Doty, Aug 03 2020 *)
  • PARI
    {u=[a=0];(chk(n)=(!#u||(n>u[1]&&!setsearch(u,n)))&&(u=setunion(u,[n]))&&!while(#u>1&&u[2]==u[1]+1,u=u[^1]));for(n=1,99,print1(a","); for(k=-primepi(a+!a-1),9e9, k||next; chk(a+sign(k)*prime(abs(k)))||next; a+=sign(k)*prime(abs(k));break))}
    
  • PARI
    A277618(n,i=[0,2,4,1,3])=i[n%#i+1]+n\#i*#i

Formula

a(n) = a(n-5) + 5 for all n > 5.
a(n) = A065186(n+1) - 1.
G.f.: x*(2*x^4 + 2*x^3 - 3*x^2 + 2*x + 2)/(x^6 - x^5 - x + 1). - Chai Wah Wu, Mar 30 2023

Extensions

Offset corrected by R. J. Mathar, Jun 19 2021

A277617 Lexicographically earliest positive sequence such that a(n+1)-a(n) is a square > 1 and no number occurs twice; a(1) = 1.

Original entry on oeis.org

1, 5, 9, 13, 4, 8, 12, 3, 7, 11, 2, 6, 10, 14, 18, 22, 26, 17, 21, 25, 16, 20, 24, 15, 19, 23, 27, 31, 35, 39, 30, 34, 38, 29, 33, 37, 28, 32, 36, 40, 44, 48, 52, 43, 47, 51, 42, 46, 50, 41, 45, 49, 53, 57, 61, 65, 56, 60, 64, 55, 59, 63, 54, 58, 62, 66, 70, 74, 78, 69, 73, 77, 68, 72, 76, 67, 71, 75, 79, 83, 87, 91, 82, 86, 90, 81, 85, 89, 80, 84, 88
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Oct 23 2016

Keywords

Comments

A variant of A277616, which is defined in the same way but starts with a(0) = 0.
Another variant is A277618, which is defined in a similar way, but with primes instead of squares. (The strictly positive variant is A065186.)

Crossrefs

Programs

  • Mathematica
    LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1}, {1, 5, 9, 13, 4, 8, 12, 3, 7, 11, 2, 6, 10, 14}, 100] (* Paolo Xausa, Jan 16 2025 *)
  • PARI
    {u=[a=1];(chk(n)=(!#u||(n>u[1]&&!setsearch(u,n)))&&(u=setunion(u,[n]))&&!while(#u>1&&u[2]==u[1]+1,u=u[^1]));for(n=1,99,print1(a",");for(k=-sqrtint(a+!a-1),9e9,k^2>1||next;chk(a+k*abs(k))||next;a+=k*abs(k);break))}

Formula

From Chai Wah Wu, Mar 30 2023: (Start)
a(n) = a(n-1) + a(n-13) - a(n-14) for n > 14.
G.f.: x*(3*x^13 + 4*x^12 + 4*x^11 - 9*x^10 + 4*x^9 + 4*x^8 - 9*x^7 + 4*x^6 + 4*x^5 - 9*x^4 + 4*x^3 + 4*x^2 + 4*x + 1)/(x^14 - x^13 - x + 1). (End)

A379057 a(0) = 0; thereafter a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference between a(n-1) and a(n) is a square > 1; in case of a tie, preference is given to the positive value.

Original entry on oeis.org

0, 4, -5, -1, 3, -6, -2, 2, 6, -3, 1, 5, -4, -8, 8, 12, -13, -9, 7, 11, -14, -10, 15, 19, 10, 14, -11, -7, 9, 13, -12, -16, 20, 16, -20, -24, -15, -19, 17, 21, 25, 29, 33, 24, -25, -21, -17, -26, -22, -18, 18, 22, 26, -23, -27, -31, -35, -39, -30, 34, 30, -34
Offset: 0

Views

Author

N. J. A. Sloane, Dec 25 2024

Keywords

Comments

Inspired by A377091 and A277616.

Crossrefs

Cf. A277616, A377091, A379058 (first differences), A380313 (partial sums).

Programs

  • Mathematica
    A379057list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || Abs[# - a] <= 1 || !IntegerQ[Sqrt[Abs[# - a]]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0, nmax]];
    A379057list[100] (* Paolo Xausa, Mar 21 2025 *)
  • Python
    from math import isqrt
    from itertools import count, islice
    def cond(n): return n > 1 and isqrt(n)**2 == n
    def agen(): # generator of terms
        an, aset, m = 0, {0}, 1
        for n in count(0):
            yield an
            an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s)))
            aset.add(an)
            while m in aset and -m in aset: m += 1
    print(list(islice(agen(), 62))) # Michael S. Branicky, Dec 25 2024

Extensions

More terms from Michael S. Branicky, Dec 25 2024

A379675 a(0) = 0, and for any n > 0, a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference of a(n-1) and a(n) is a square and a(n) is positive iff n is odd.

Original entry on oeis.org

0, 1, -3, 6, -10, 15, -1, 3, -6, 10, -15, 21, -4, 5, -11, 14, -2, 2, -7, 9, -16, 20, -5, 4, -12, 13, -23, 26, -38, 11, -14, 22, -27, 37, -44, 56, -8, 8, -17, 19, -30, 34, -47, 17, -19, 30, -34, 47, -53, 28, -21, 43, -57, 7, -9, 16, -20, 29, -35, 46, -18, 18
Offset: 0

Views

Author

Rémy Sigrist, Dec 29 2024

Keywords

Comments

This sequence is a variant of A377091 where, beyond the initial term a(0) = 0, the sign of the terms alternates.
Will every integer appear in the sequence?

Examples

			The first terms are:
  n   a(n)  |a(n)-a(n-1)|
  --  ----  -------------
   0     0  N/A
   1     1  1^2
   2    -3  2^2
   3     6  3^2
   4   -10  4^2
   5    15  5^2
   6    -1  4^2
   7     3  2^2
   8    -6  3^2
   9    10  4^2
  10   -15  5^2
  11    21  6^2
  12    -4  5^2
  13     5  3^2
  14   -11  4^2
		

Crossrefs

Programs

  • PARI
    \\ See Links section.

A344538 Lexicographically earliest sequence such that |a(n+1)-a(n)| is a cube > 1 and no number occurs twice; a(0) = 0.

Original entry on oeis.org

0, 8, 16, 24, 32, 5, 13, 21, 29, 2, 10, 18, 26, 34, 7, 15, 23, 31, 4, 12, 20, 28, 1, 9, 17, 25, 33, 6, 14, 22, 30, 3, 11, 19, 27, 35, 43, 51, 59, 67, 40, 48, 56, 64, 37, 45, 53, 61, 69, 42, 50, 58, 66, 39, 47, 55, 63, 36, 44, 52, 60, 68, 41, 49, 57, 65, 38
Offset: 0

Views

Author

Mike Koss, May 22 2021

Keywords

Comments

The difference between successive terms, a(n+1)-a(n), is either +8 or -27. This sequence is a permutation of the nonnegative integers (with no "gaps").

Crossrefs

Cf. A277616.

Programs

  • Mathematica
    a[0]=0;a[n_]:=a[n]=(k=1;While[!IntegerQ[s=Abs[k-a[n-1]]^(1/3)]||s==1||MemberQ[Array[a,n-1],k],k++];k);Array[a,100,0] (* Giorgos Kalogeropoulos, May 27 2021 *)

Formula

a(n+35) = a(n) + 35 for all n.
a(n) = 2*a(n-1) - a(n-2) - a(n-7) + 2*a(n-8) - a(n-9) - a(n-14) + 2*a(n-15) - a(n-16) - a(n-21) + 2*a(n-22) - a(n-23) - a(n-28) + 2*a(n-29) - a(n-30) for n > 29. - Stefano Spezia, May 23 2021
Showing 1-6 of 6 results.