A335923 A variation on Recamán's sequence (A005132): a(0) = 0, a(n) = a(n-1) - n if a(n) is nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + ceiling(n/2).
0, 1, 2, 4, 6, 9, 3, 7, 11, 16, 21, 10, 16, 23, 30, 15, 23, 32, 14, 24, 34, 13, 24, 36, 12, 25, 38, 52, 66, 37, 52, 68, 84, 51, 17, 35, 53, 72, 91, 111, 71, 92, 50, 72, 28, 51, 5, 29, 53, 78, 103, 129, 77, 104, 131, 76, 20, 49, 78, 19, 49, 80, 18, 50, 82, 115
Offset: 0
Keywords
Programs
-
Python
import math n_max = 1000000 a_last = 0 list1 = [a_last] print(0) for n in range(1, n_max+1): m = a_last - n if m >= 0 and m not in list1: a = m else: a = a_last + math.ceil(n/2) list1.append(a) print(a) a_last = a
Comments