login
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).
1
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,3
COMMENTS
In this sequence the forward step is reduced from n to ceiling(n/2). As a result, the number of distinct numbers in the sequence as a percentage of the biggest number in the sequence (called "coverage") is increased. For example, for n<=1000000, the number of distinct numbers in this sequence is 694811 and the biggest number is 4350902, giving a coverage of about 15.97% (694811/4350902), higher than that of A005132 (736749/5946126, or about 12.39%).
The smallest missing numbers, h1, from the first m terms of the sequence, given as h1(m), are: 3(6), 5(46), 8(74), 22(646), 33(2551), 114(6009), 166(95445), 331(591310), ... In other words, all integers less than or equal to h1 can be found in the first m+1 terms of the sequence.
PROG
(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
CROSSREFS
Sequence in context: A361973 A021409 A283501 * A335924 A369543 A248761
KEYWORD
nonn
AUTHOR
Ya-Ping Lu, Jun 29 2020
STATUS
approved