cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A335924 #33 Sep 16 2022 02:14:48
%S A335924 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,
%T A335924 71,45,18,46,17,47,63,79,96,62,27,63,26,64,25,65,24,66,88,44,67,90,43,
%U A335924 91,42,92,41,93,40,94,39,95,38,96,37,97,36,98,35,99,132,165
%N 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.
%C A335924 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.
%C A335924 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.
%C A335924 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:
%C A335924 Sequence  Backward  Forward      Nc     Nd       a_max     coverage
%C A335924 A005132   -n        +n           1355   736749   5946126   12.39%
%C A335924 A335923   -n        +n/2          620   694811   4350902   15.97%
%C A335924 "B"       -n        +n/4          577   696167   3132344   22.23%
%C A335924 A335924   -n        +n/2, +n      160   813204   5698099   14.27%
%C A335924 "C"       -n        +n/4, +n/2   1330   779087   3757167   20.74%
%C A335924 "D"       -2n, -n   +n/2, +n       24   901949   3639015   24.79%
%C A335924 "E"       -2n, -n   +n/4, +n/2   3414   817174   3128675   26.12%
%H A335924 Michael De Vlieger, <a href="/A335924/b335924.txt">Table of n, a(n) for n = 0..10000</a>
%H A335924 Altug Alkan, Andrew R. Booker, and Florian Luca, <a href="https://arxiv.org/abs/2006.08013">On a recursively defined sequence involving the prime counting function</a>, arXiv:2006.08013 [math.NT], 2020.
%t A335924 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 *)
%o A335924 (Python)
%o A335924 import math
%o A335924 n_max = 1000000
%o A335924 a_last = 0
%o A335924 list1 = [a_last]
%o A335924 print(0)
%o A335924 for n in range(1, n_max+1):
%o A335924     m1 = a_last - n
%o A335924     m2 = a_last + math.ceil(n/2)
%o A335924     if m1 >= 0 and m1 not in list1:
%o A335924         a = m1
%o A335924     elif m2 not in list1:
%o A335924         a = m2
%o A335924     else:
%o A335924         a = a_last + n
%o A335924     list1.append(a)
%o A335924     print(a)
%o A335924     a_last = a
%o A335924 (Python)
%o A335924 from itertools import count, islice
%o A335924 def A335924_gen(): # generator of terms
%o A335924     a, aset = 0, set()
%o A335924     for n in count(1):
%o A335924         yield a
%o A335924         aset.add(a)
%o A335924         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
%o A335924 A335924_list = list(islice(A335924_gen(),70)) # _Chai Wah Wu_, Sep 15 2022
%Y A335924 Cf. A005132, A335923.
%K A335924 nonn
%O A335924 0,3
%A A335924 _Ya-Ping Lu_, Jun 29 2020