login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A254868 Recamán [-, +, *]-sequence with seed 6 and step 4. 2

%I #36 Jun 02 2021 07:30:42

%S 6,2,8,4,16,12,48,44,40,36,32,28,24,20,80,76,72,68,64,60,56,52,208,

%T 204,200,196,192,188,184,180,176,172,168,164,160,156,152,148,144,140,

%U 136,132,128,124,120,116,112,108,104,100,96,92,88,84,336,332,328,324

%N Recamán [-, +, *]-sequence with seed 6 and step 4.

%C 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.

%C More chaotic sequences are obtained if division is included: cf. A254873.

%C These sequences were first explored by Brian Kehrig, a 15-year-old student at Renert School, Calgary, Canada.

%C They are exceptionally nice sequences to introduce to the elementary school math classroom.

%C Like many Recamán sequences, this is worth listening to.

%H Reinhard Zumkeller, <a href="/A254868/b254868.txt">Table of n, a(n) for n = 1..100000</a>

%e 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 ...

%o (Sage)

%o A=[6]

%o step=4

%o for i in [1..100]:

%o if A[i-1]-step>0 and (A[i-1]-step) not in A:

%o A.append(A[i-1]-step)

%o else:

%o if not((A[i-1]+step) in A):

%o A.append(A[i-1]+step)

%o else:

%o A.append(step*A[i-1])

%o A # - _Tom Edgar_, Feb 16 2015

%o (Haskell)

%o import Data.Set (Set, singleton, notMember, insert)

%o a254868 n = a254868_list !! (n-1)

%o a254868_list = 6 : kehrig (singleton 6) 6 where

%o kehrig s x | x > 4 && (x - 4) `notMember` s =

%o (x - 4) : kehrig (insert (x - 4) s) (x - 4)

%o | (x + 4) `notMember` s =

%o (x + 4) : kehrig (insert (x + 4) s) (x + 4)

%o | otherwise =

%o (x * 4) : kehrig (insert (x * 4) s) (x * 4)

%o -- _Reinhard Zumkeller_, Feb 25 2015

%o (Python)

%o from sympy import primerange, prime

%o def aupton(nn, seed=6, step=4):

%o alst, step = [seed], step

%o for n in range(1, nn+1, 1):

%o x, y, z = alst[-1] - step, alst[-1] + step, alst[-1] * step

%o if x > 0 and x not in alst: alst.append(x)

%o elif y > 0 and y not in alst: alst.append(y)

%o elif z > 0 and z not in alst: alst.append(z)

%o else: break

%o return alst

%o print(aupton(57)) # _Michael S. Branicky_, Jun 02 2021

%Y Cf. A005132 (original Recamán sequence).

%Y Cf. A254873 (an example with division at the top in the hierarchy of operations).

%K easy,hear,nonn

%O 1,1

%A _Gordon Hamilton_, Feb 09 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)