A113880 Variation on Recamán's sequence utilizing the four basic operations (/,-,+,*) in that order.
0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 432, 407, 381, 354, 326, 297, 267, 236, 204, 171, 137, 102, 66, 29, 67, 28, 68, 27, 69, 26, 70, 115, 161, 114, 162, 113, 163, 112, 60, 3180, 3126, 3071, 3015, 2958, 51, 110, 50, 111, 49
Offset: 0
Keywords
Examples
a(24) = 432 because: - a(23) = 18, - 18/24 is not an integer, - 18 - 24 is negative, - 18 + 24 = 42 is already in the sequence, - 18 * 24 = 432 is not already in the sequence.
Links
Crossrefs
Cf. A005132.
Programs
-
Mathematica
f[s_List] := Block[{l = s[[-1]], n = Length@ s}, If[ IntegerQ[l/n] && !MemberQ[s, l/n], Append[s, l/n], If[l > n && !MemberQ[s, l - n], Append[s, l - n], If[ !MemberQ[s, l + n], Append[s, l + n], Append[s, l*n]]]]]; Nest[f, {0}, 62] (* Robert G. Wilson v, Sep 10 2016 *)
-
Python
from itertools import count, islice def A113880(): # generator of terms aset, an = {0, 1}, 1 yield from [0, 1] for n in count(2): q, r = divmod(an, n) if r == 0 and q not in aset: an = q elif (d:=an-n) > 0 and d not in aset: an = d elif (s:=an+n) not in aset: an = s elif (m:=an*n) not in aset: an = m else: return yield an aset.add(an) print(list(islice(A113880(), 63))) # Michael S. Branicky, May 26 2023
Extensions
a(0) = 0 prepended by Robert G. Wilson v, Sep 10 2016
Comments