Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A339238
a(1)=a(2)=1 and, for n >= 3, a(n) = a(n-1) + a(n-2) - Sum_{i=3..k} primepi(a(n-i)), where k is the largest integer such that a(n) >=2 and not already in the sequence.
0
1, 1, 2, 3, 5, 7, 9, 10, 12, 11, 15, 13, 14, 16, 18, 22, 28, 19, 20, 30, 25, 39, 21, 33, 42, 36, 38, 50, 45, 40, 23, 34, 57, 29, 54, 35, 17, 52, 58, 66, 49, 77, 92, 61, 68, 51, 101, 37, 8, 45, 41, 44, 55, 72, 70, 43, 93, 67, 91, 120, 85, 105, 117, 69, 63, 75
OFFSET
1,3
FORMULA
a(n) = a(n-1) + a(n-2) - Sum_{i=3..k} primepi(a(n-i)), where a(1)=a(2)=1 and k<=n-3 such that a(n) >= 2 and not in {a(i), i=1..n-1}.
PROG
(Python)
from sympy import primepi
a_1 = a_2 = 1
print(a_2, "\n", a_1)
list1 = [a_1, a_2]
for n in range(3, 1001):
a = a_1 + a_2
i = 2
while i < len(list1):
d = a - primepi(list1[i])
if d >= 2 and d not in list1: a = d
else: break
i += 1
list1.insert(0, a)
a_2 = a_1
a_1 = a
print(a)
CROSSREFS
KEYWORD
nonn
AUTHOR
Ya-Ping Lu, Nov 28 2020
STATUS
approved