login
A254868
Recamán [-, +, *]-sequence with seed 6 and step 4.
2
6, 2, 8, 4, 16, 12, 48, 44, 40, 36, 32, 28, 24, 20, 80, 76, 72, 68, 64, 60, 56, 52, 208, 204, 200, 196, 192, 188, 184, 180, 176, 172, 168, 164, 160, 156, 152, 148, 144, 140, 136, 132, 128, 124, 120, 116, 112, 108, 104, 100, 96, 92, 88, 84, 336, 332, 328, 324
OFFSET
1,1
COMMENTS
Starting at the seed number (6) the sequence continues by subtracting, adding or multiplying by the step number (4). Subtracting gets precedence over addition which gets precedence over multiplication. The new number must be a positive integer and not previously listed. The sequence terminates if this is impossible, but for this seed (6) and step (4) the sequence is infinite.
More chaotic sequences are obtained if division is included: cf. A254873.
These sequences were first explored by Brian Kehrig, a 15-year-old student at Renert School, Calgary, Canada.
They are exceptionally nice sequences to introduce to the elementary school math classroom.
Like many Recamán sequences, this is worth listening to.
LINKS
EXAMPLE
a(1) = 6. a(2) = 6-4 = 2. a(3) = 2*4 = 8. a(4) = 8-4 = 4. a(5) = 4*4 = 16. a(6) = 16-4 = 12. a(7) = 12*4 = 48 ...
PROG
(Sage)
A=[6]
step=4
for i in [1..100]:
if A[i-1]-step>0 and (A[i-1]-step) not in A:
A.append(A[i-1]-step)
else:
if not((A[i-1]+step) in A):
A.append(A[i-1]+step)
else:
A.append(step*A[i-1])
A # - Tom Edgar, Feb 16 2015
(Haskell)
import Data.Set (Set, singleton, notMember, insert)
a254868 n = a254868_list !! (n-1)
a254868_list = 6 : kehrig (singleton 6) 6 where
kehrig s x | x > 4 && (x - 4) `notMember` s =
(x - 4) : kehrig (insert (x - 4) s) (x - 4)
| (x + 4) `notMember` s =
(x + 4) : kehrig (insert (x + 4) s) (x + 4)
| otherwise =
(x * 4) : kehrig (insert (x * 4) s) (x * 4)
-- Reinhard Zumkeller, Feb 25 2015
(Python)
from sympy import primerange, prime
def aupton(nn, seed=6, step=4):
alst, step = [seed], step
for n in range(1, nn+1, 1):
x, y, z = alst[-1] - step, alst[-1] + step, alst[-1] * step
if x > 0 and x not in alst: alst.append(x)
elif y > 0 and y not in alst: alst.append(y)
elif z > 0 and z not in alst: alst.append(z)
else: break
return alst
print(aupton(57)) # Michael S. Branicky, Jun 02 2021
CROSSREFS
Cf. A005132 (original Recamán sequence).
Cf. A254873 (an example with division at the top in the hierarchy of operations).
Sequence in context: A079718 A062771 A249919 * A071874 A011331 A155687
KEYWORD
easy,hear,nonn
AUTHOR
Gordon Hamilton, Feb 09 2015
STATUS
approved