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, 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
Links
- Yifan Xie, Table of n, a(n) for n = 1..2000
Programs
-
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 *)
-
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
Comments