login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A363198
a(n) = n for n <= 3; for n >= 4, a(n) is the smallest positive integer that has not appeared previously in this sequence and shares a factor with a(n-1) + a(n-2) + a(n-3).
1
1, 2, 3, 4, 6, 13, 23, 7, 43, 73, 9, 5, 12, 8, 10, 14, 16, 15, 18, 21, 20, 59, 22, 101, 24, 27, 19, 25, 71, 30, 26, 127, 33, 28, 32, 31, 35, 34, 36, 39, 109, 38, 40, 11, 89, 42, 44, 45, 131, 46, 37, 48, 262, 347, 51, 50, 49, 52, 151, 54, 257, 55, 56, 58, 65
OFFSET
1,2
COMMENTS
Conjecture: This sequence is a permutation of the natural numbers.
MATHEMATICA
a[1] = 1; a[2] = 2; a[3] = 3; a[n_] := a[n] = Module[{s, i = 1}, s = a[n - 1] + a[n - 2] + a[n - 3]; While[MemberQ[a /@ Range[1, n - 1], i] || GCD[s, i] == 1, i++]; i];
Table[a[n], {n, 1, 65}] (* Robert P. P. McKone, Dec 30 2023 *)
PROG
(PARI) lista(nn) = {my(v = [1, 2, 3]); for(n=4, nn, my(t=1); while(prod(X=1, n-1, v[X]-t)==0 || gcd(v[n-3]+v[n-2]+v[n-1], t)==1, t++); v=concat(v, t)); v; }
(Python)
from math import gcd
a = [1, 2, 3]
t = set(a)
def next_element():
s = a[-1] + a[-2] + a[-3]
n = 1
while n in t or gcd(s, n) == 1:
n += 1
return n
def a_seq(ul):
for _ in range(4, ul + 1):
nn = next_element()
a.append(nn)
t.add(nn)
return a
print(a_seq(65)) # Robert P. P. McKone, Dec 30 2023
CROSSREFS
Sequence in context: A066463 A073146 A038767 * A188715 A369849 A174046
KEYWORD
nonn,easy
AUTHOR
Yifan Xie, May 21 2023
STATUS
approved