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.

A377090 a(0) = 0; thereafter, for n > 0, 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 prime number; in case of a tie, preference is given to the positive value.

This page as a plain text file.
%I A377090 #48 Apr 30 2025 13:47:48
%S A377090 0,2,-1,1,-2,3,-4,-6,-3,4,6,-5,-7,-9,8,5,7,9,-8,-10,-12,11,13,10,12,
%T A377090 -11,-13,-15,14,16,18,15,-14,-16,-18,19,17,20,-17,-19,-21,22,24,21,
%U A377090 -20,-22,-24,23,25,27,-26,-23,-25,-27,26,28,30,-29,-31,-28,-30,29
%N A377090 a(0) = 0; thereafter, for n > 0, 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 prime number; in case of a tie, preference is given to the positive value.
%C A377090 This sequence is a variant of A277618 allowing negative values.
%C A377090 Will every integer appear in the sequence?
%C A377090 Conjecture (after studying A383445 and A383446): The sequence contains every integer. - _N. J. A. Sloane_, Apr 30 2025
%C A377090 The distances d(n) = |a(n)| - n/2 remain very small. Records values of |d(n)| appear at d(1) = 1.5, d(7) = 2.5, d(30) = 3.0, d(117) = 3.5, d(124) = -4.0, d(326) = -5.0, d(530) = 6.0, d(1137) = 6.5, d(1142) = -7.0, d(1342) = 8.0, d(5363) = 8.5, d(5370) = -9.0, d(9567) = 9.5, d(9568) = 10.0, ... - _M. F. Hasler_, Feb 10 2025
%H A377090 Paolo Xausa, <a href="/A377090/b377090.txt">Table of n, a(n) for n = 0..10000</a> (terms 0..1000 from Rémy Sigrist).
%H A377090 Rémy Sigrist, <a href="/A377090/a377090.png">Scatterplot of the first 100000 terms of the partial sums</a>
%H A377090 Rémy Sigrist, <a href="/A377090/a377090.gp.txt">PARI program</a>
%F A377090 ||a(n)| - n/2| = O(log(n)), probably ||a(n)| - n/2| < 2 log(n+2) for all n. (Conjectured; verified up to n = 10^5.) - M. F. Hasler, Feb 21 2025
%e A377090 The first terms are:
%e A377090    n   a(n)  |a(n)-a(n-1)|
%e A377090   --- ------ -------------
%e A377090    0     0        N/A
%e A377090    1     2         2
%e A377090    2    -1         3
%e A377090    3     1         2
%e A377090    4    -2         3
%e A377090    5     3         5
%e A377090    6    -4         7
%e A377090    7    -6         2
%e A377090    8    -3         3
%e A377090    9     4         7
%e A377090   10     6         2
%e A377090   11    -5        11
%e A377090   12    -7         2
%e A377090   13    -9         2
%e A377090   14     8        17
%t A377090 A377090list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || !PrimeQ[Abs[# - a]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0,nmax]];
%t A377090 A377090list[100] (* _Paolo Xausa_, Mar 27 2025 *)
%o A377090 (PARI) \\ See Links section.
%o A377090 (PARI) A377090_first(N, L=1, U=[])={vector(N, n, while(setsearch(U,L), U=setminus(U,[L]); L=(L<0)-L); N=if(n>1, n=L; while(!isprime(abs(n-N)) || setsearch(U, n), n=(n<0)-n); U=setunion(U, [n]); n))} \\ _M. F. Hasler_, Feb 21 2025
%o A377090 (Python)
%o A377090 from sympy import isprime
%o A377090 from itertools import count, islice
%o A377090 def cond(n): return isprime(n)
%o A377090 def agen(): # generator of terms
%o A377090     an, aset, m = 0, {0}, 1
%o A377090     for n in count(0):
%o A377090         yield an
%o A377090         an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s)))
%o A377090         aset.add(an)
%o A377090         while m in aset and -m in aset: m += 1
%o A377090 print(list(islice(agen(), 62))) # _Michael S. Branicky_, Dec 27 2024
%o A377090 (Python)
%o A377090 from sympy import isprime
%o A377090 def A377090(n):
%o A377090     while len(terms := A377090.terms) <= n:
%o A377090         while (k := A377090.N) in terms: A377090.N = (k<0)-k
%o A377090         while not isprime(abs(k - terms[-1])) or k in terms: k = (k<0)-k
%o A377090         terms.append(k)
%o A377090     return terms[n]
%o A377090 A377090.terms = [0]; A377090.N = 1 # least unused candidate
%o A377090 # _M. F. Hasler_, Feb 10 2025, simplified Feb 15 2025
%Y A377090 Cf. A277618, A377091, A377092, A380311 (partial sums), A383444 (differences), A383445, A383446.
%K A377090 sign,look
%O A377090 0,2
%A A377090 _Rémy Sigrist_, Oct 16 2024