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.

A377092 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 Fibonacci number (A000045); in case of a tie, preference is given to the positive value.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Oct 16 2024

Keywords

Comments

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    -1        2
   3     2        3
   4     3        1
   5    -2        5
   6    -3        1
   7    -4        1
   8     4        8
   9     5        1
  10     6        1
  11     7        1
  12    -6       13
  13    -5        1
  14    -7        2
The first terms are a(0) = 0, a(1) = 1 and a(2) = -1, clearly the |smallest| unused number so far, which yields |a(2)-a(1)| = 2, a Fibonacci number. - _M. F. Hasler_, Feb 21 2025
		

Crossrefs

Cf. A000045, A377090, A377091, A380320 (first differences), A380321 (partial sums).
Cf. A010056 (characteristic function of the Fibonacci numbers).

Programs

  • Mathematica
    A377092list[nmax_] := Module[{s, a, u = 1, fibQ},
      fibQ[n_] := fibQ[n] = (IntegerQ[Sqrt[# + 4]] || IntegerQ[Sqrt[# - 4]]) & [5*n^2];
      s[_] := False; s[0] = True;
      NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || !fibQ[Abs[# - a]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0,nmax]];
    A377092list[100] (* Paolo Xausa, Apr 19 2025 *)
  • PARI
    \\ See Links section.
    
  • PARI
    A377092_upto(N, U=[-1])={vector(N, n, if(n>1, for(k=U[1]+1,oo, A010056(k-N) && !setsearch(U, k) && [N=k, break]), N=0); U=setunion(U,[N]); while(#U>1&&U[1]+1==U[2],U=U[^1]); N)} \\ M. F. Hasler, Feb 21 2025
    
  • Python
    def A377092(n):
        if not getattr(A := A377092, 'N', 0):  A.N = 1; A.terms = [0]
        while len(A.terms) <= n:
            while (k := A.N) in A.terms: A.N = (k<0)-k
            while not A010056(abs(k - A.terms[-1])) or k in A.terms: k = (k<0)-k
            A.terms.append(k)
        return A.terms[n] # M. F. Hasler, Feb 10 2025