login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

The Sydney Opera House sequence: a(0) = 0, a(1) = 1; for n > 0, a(n) = min(a(n-1)/n if n|a(n-1), a(n-1)-n) where a(n) is nonnegative and not already in the sequence. Otherwise a(n) = min(a(n-1)+n, a(n-1)*n) where a(n) is not already in the sequence. Otherwise a(n) = a(n-1) + n.
3

%I #53 May 27 2023 03:14:26

%S 0,1,2,5,9,4,10,3,11,20,30,19,7,91,77,62,46,29,47,28,8,168,146,123,99,

%T 74,48,21,49,78,108,139,107,140,106,71,35,72,34,73,33,1353,1311,1268,

%U 1224,1179,1133,1086,1038,989,939,888,836,783,729,674,618,561,503,444,384,323,261

%N The Sydney Opera House sequence: a(0) = 0, a(1) = 1; for n > 0, a(n) = min(a(n-1)/n if n|a(n-1), a(n-1)-n) where a(n) is nonnegative and not already in the sequence. Otherwise a(n) = min(a(n-1)+n, a(n-1)*n) where a(n) is not already in the sequence. Otherwise a(n) = a(n-1) + n.

%C This sequence is similar to the Recamán sequence A005132 except that division and multiplication by n are also permitted. This leads to larger variations in the values of the terms while minimizing the repetition of previously visited terms.

%C To determine a(n), initially a(n-1)-n is calculated if a(n-1)-n is nonnegative, along with a(n-1)/n if n|a(n-1). If one or both of these have not already appeared in the sequence then a(n) is set to the minimum of these candidates. If neither are candidates then both a(n-1)+n and a(n-1)*n are calculated. If one or both of these have not already appeared in the sequence then a(n) is set to the minimum of these candidates. If neither are candidates, i.e., all of a(n-1)-n, a(n-1)/n, a(n-1)+n, a(n-1)*n are either invalid or have already been visited, then a(n) = a(n-1)+n. However for the first 100 million terms no instance is found where all four options are unavailable, although it is unknown if this eventually occurs for very large n.

%C For the first 100 million terms the smallest value not appearing is 6. As with the Recamán sequence it is unknown if this and other small unseen terms eventually appear. The largest term is a(50757703) = 6725080695952885. In the same range, division, subtraction, addition, and multiplication are chosen for the next term 38, 99965692, 34188, and 81 times, respectively.

%H Michael S. Branicky, <a href="/A336830/b336830.txt">Table of n, a(n) for n = 0..20000</a>

%H Scott R. Shannon, <a href="/A336830/a336830.png">Line graph of the first 10 million terms</a>.

%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>

%e a(2) = 2. As a(1) = 1, which is not divisible by 2 nor greater than 2, a(2) must be the minimum of 1*2=2 and 1+2=3, so multiplication is chosen.

%e a(5) = 4. As a(4) = 9, which is not divisible by 5, and 4 has not appeared previously in the sequence, a(5) = a(4)-5 = 9-5 = 4.

%e a(82) = 52. As a(81) = 4264 one candidate is 4264-82 = 4182. However 82|4264 and 4264/82 = 52. Neither of these candidates has previously appeared in the sequence, but 52 is the minimum of the two. This is the first time a division operation is used for a(n).

%o (Python)global arr

%o arr = []

%o def a(n):

%o # Case 1

%o if n == 0:

%o return 0

%o a_prev = arr[-1]

%o cand = []

%o # Case 2

%o x = a_prev - n

%o y = a_prev / n

%o if x > 0 and not x in arr:

%o cand.append(x)

%o if y == int(y) and not y in arr:

%o cand.append(y)

%o if cand != []:

%o return min(cand)

%o # Case 3

%o cand = []

%o x = a_prev + n

%o y = a_prev * n

%o if not x in arr:

%o cand.append(x)

%o if not y in arr:

%o cand.append(y)

%o if cand != []:

%o return min(cand)

%o # Case 4

%o return a_prev + n

%o def seq(n):

%o for i in range(n):

%o print("{}, ".format(a(i)), end="")

%o arr.append(a(i))

%o seq(60)

%o # _Christoph B. Kassir_, Apr 08 2022

%o (Python)

%o from itertools import count, islice

%o def A336830(): # generator of terms

%o aset, an, oo = {0, 1}, 1, float('inf')

%o yield from [0, 1]

%o for n in count(2):

%o v1, v2 = an - n if an >= n else oo, an//n if an%n == 0 else oo

%o v = min((vi for vi in [v1, v2] if vi not in aset), default=oo)

%o if v != oo: an = v

%o else:

%o v3, v4 = an+n, an*n

%o v = min((vi for vi in [v3, v4] if vi not in aset), default=oo)

%o if v != oo: an = v

%o else: an = an+n

%o yield an

%o aset.add(an)

%o print(list(islice(A336830(), 60))) # _Michael S. Branicky_, Apr 15 2023

%Y Cf. A005132, A113880, A171884, A330791, A362398, A362399.

%K nonn

%O 0,3

%A _Scott R. Shannon_, Aug 05 2020