login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A335924 A variation on Recamán's sequence (A005132): a(0) = 0, a(n) = a(n-1) - n if nonnegative and not already in the sequence; otherwise, a(n) = a(n-1) + ceiling(n/2) if not already in the sequence and a(n) = a(n-1) + n if already in the sequence. 2
0, 1, 2, 4, 6, 9, 3, 7, 11, 16, 21, 10, 22, 29, 15, 23, 31, 14, 32, 13, 33, 12, 34, 46, 58, 71, 45, 18, 46, 17, 47, 63, 79, 96, 62, 27, 63, 26, 64, 25, 65, 24, 66, 88, 44, 67, 90, 43, 91, 42, 92, 41, 93, 40, 94, 39, 95, 38, 96, 37, 97, 36, 98, 35, 99, 132, 165 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
In this sequence, a forward step of ceiling(n/2) is added if a(n) - n is negative and a(n-1) + ceiling(n/2) is not already in the sequence. As a result, both the number of distinct numbers and the number of distinct numbers as a percentage of the biggest number in the sequence (called "coverage") are increased.
The smallest missing numbers, h1, from the first m terms of the sequence, given as h1(m), are: 3(6), 5(11097), 57(49518), 149(92113), 159(124908), ... All integers less than or equal to h1 can be found in the first m+1 terms of the sequence.
The number of consecutive numbers (Nc, from 0 to Nc-1), the distinct numbers (Nd), the biggest number (a_max), and the "coverage" for n=0~1000000 in the sequences with different forward and backward steps are given below:
Sequence Backward Forward Nc Nd a_max coverage
A005132 -n +n 1355 736749 5946126 12.39%
A335923 -n +n/2 620 694811 4350902 15.97%
"B" -n +n/4 577 696167 3132344 22.23%
A335924 -n +n/2, +n 160 813204 5698099 14.27%
"C" -n +n/4, +n/2 1330 779087 3757167 20.74%
"D" -2n, -n +n/2, +n 24 901949 3639015 24.79%
"E" -2n, -n +n/4, +n/2 3414 817174 3128675 26.12%
LINKS
Altug Alkan, Andrew R. Booker, and Florian Luca, On a recursively defined sequence involving the prime counting function, arXiv:2006.08013 [math.NT], 2020.
MATHEMATICA
Nest[Append[#1, If[And[#3 >= 0, FreeQ[#1, #3]], #3, If[FreeQ[#1, #4], #4, #1[[-1]] + #2]]] & @@ {#1, #2, #1[[-1]] - #2, #1[[-1]] + Ceiling[#2/2]} & @@ {#, Length@ #} &, {0}, 10^5] (* Michael De Vlieger, Sep 09 2020 *)
PROG
(Python)
import math
n_max = 1000000
a_last = 0
list1 = [a_last]
print(0)
for n in range(1, n_max+1):
m1 = a_last - n
m2 = a_last + math.ceil(n/2)
if m1 >= 0 and m1 not in list1:
a = m1
elif m2 not in list1:
a = m2
else:
a = a_last + n
list1.append(a)
print(a)
a_last = a
(Python)
from itertools import count, islice
def A335924_gen(): # generator of terms
a, aset = 0, set()
for n in count(1):
yield a
aset.add(a)
a = b if (b:=a-n)>=0 and b not in aset else c if (c:=(n+1>>1)+a) not in aset else a+n
A335924_list = list(islice(A335924_gen(), 70)) # Chai Wah Wu, Sep 15 2022
CROSSREFS
Sequence in context: A021409 A283501 A335923 * A369543 A248761 A176461
KEYWORD
nonn
AUTHOR
Ya-Ping Lu, Jun 29 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 14:09 EDT 2024. Contains 371960 sequences. (Running on oeis4.)