login
A389233
a(0) = 0 and a(n) = a(n-1) - n if it is > 0 and not already in the sequence, otherwise a(n) = n*a(n-1) + 1.
1
0, 1, 3, 10, 6, 31, 25, 18, 145, 136, 126, 115, 103, 90, 76, 61, 45, 28, 505, 486, 466, 445, 423, 400, 376, 351, 325, 298, 270, 241, 211, 180, 148, 4885, 4851, 4816, 4780, 4743, 4705, 4666, 4626, 4585, 4543, 4500, 4456, 4411, 4365, 4318, 4270, 4221, 4171, 4120
OFFSET
0,3
COMMENTS
Modification of the classical Recaman sequence (A005132), with a multiplicative fallback rule.
LINKS
EXAMPLE
a(0) = 0.
n = 1: 0 - 1 < 0 -> a(1) = 0*1 + 1 = 1.
n = 2: 1 - 2 < 0 -> a(2) = 1*2 + 1 = 3.
n = 3: 3 - 3 = 0 (already in sequence) -> a(3) = 3*3 + 1 = 10.
n = 4: 10 - 4 = 6 -> new -> a(4) = 6.
Sequence begins: 0, 1, 3, 10, 6, 31, 25, 18, 145, ...
MATHEMATICA
s={0}; Do[If[!MemberQ[s, s[[-1]]-n]&&s[[-1]]-n>0, AppendTo[s, s[[-1]]-n], AppendTo[s, n*s[[-1]]+1]], {n, 51}]; s (* James C. McMahon, Nov 03 2025 *)
PROG
(Python)
def A389233_lst(n): # returns list of n terms: a(0)..a(n-1)
a, s =[0], {0}
for i in range(1, n):
p = a[-1]; c = p - i
a += [c if c > 0 and c not in s else p*i + 1]
s |= {a[-1]}
return a
print(A389233_lst(52))
CROSSREFS
Cf. A005132.
Sequence in context: A210414 A289832 A196163 * A195922 A261836 A301937
KEYWORD
nonn,easy
AUTHOR
STATUS
approved