Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A005132
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A005132 Recaman's sequence: a(0) = 0; for n > 0, a(n) = a(n-1)-n if that number is positive and not already in the sequence, otherwise a(n) = a(n-1)+n.
(Formerly M2511)
+0
77
0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 42, 17, 43, 16, 44, 15, 45, 14, 46, 79, 113, 78, 114, 77, 39, 78, 38, 79, 37, 80, 36, 81, 35, 82, 34, 83, 33, 84, 32, 85, 31, 86, 30, 87, 29, 88, 28, 89, 27, 90, 26 (list; graph; listen)
OFFSET

0,3

COMMENT

The name "Recaman's sequence" is due to njas, not the author!

I conjecture that every number eventually appears - see A057167, A064227, A064228. - njas.

REFERENCES

N. J. A. Sloane and A. R. Wilks, On sequences of Recaman type, paper in preparation, 2006.

LINKS

N. J. A. Sloane, The first 100000 terms

Nick Hobson, Python program for this sequence

C. L. Mallows, Plot (jpeg) of first 10000 terms

C. L. Mallows, Plot (postscript) of first 10000 terms

N. J. A. Sloane, My favorite integer sequences, in Sequences and their Applications (Proceedings of SETA '98).

N. J. A. Sloane, FORTRAN program for A005132, A057167, A064227, A064228

Index entries for sequences related to Recaman's sequence

EXAMPLE

Consider n=6. We have a(5)=7 and try to subtract 6. The result, 1, is certainly positive, but we cannot use it because 1 is already in the sequence. So we must add 6 instead, getting a(6) = 7 + 6 = 13.

MAPLE

h := array(1..100000); maxt := 100000; a := [1]; ad := [1]; su := []; h[1] := 1; for nx from 2 to 500 do t1 := a[nx-1]-nx; if t1>0 and h[t1] <> 1 then su := [op(su), nx]; else t1 := a[nx-1]+nx; ad := [op(ad), nx]; fi; a := [op(a), t1]; if t1 <= maxt then h[t1] := 1; fi; od: # a is A005132, ad is A057165, su is A057166

MATHEMATICA

a = {1}; Do[ If[ a[ [ -1 ] ] - n > 0 && Position[ a, a[ [ -1 ] ] - n ] == {}, a = Append[ a, a[ [ -1 ] ] - n ], a = Append[ a, a[ [ -1 ] ] + n ] ], {n, 2, 70} ]; a

PROGRAM

(PARI) a(n)=if(n<2, 1, if(abs(sign(a(n-1)-n)-1)+setsearch(Set(vector(n-1, i, a(i))), a(n-1)-n), a(n-1)+n, a(n-1)-n)) (from Benoit Cloitre)

CROSSREFS

Cf. A057165 (addition steps), A057166 (subtraction steps), A057167 (steps to hit n), A008336, A046901 (simplified version), A063733.

Cf. A064227 (records for reaching n), A064228 (n's that take a record number of steps to reach), A064284 (no. of times n appears), A064288, A064289, A064290 (heights of terms).

Cf. A064291 (record highs), A064387, A064388, A064389 (further variants).

A row of A066201.

Condensed version: A119632.

Adjacent sequences: A005129 A005130 A005131 this_sequence A005133 A005134 A005135

Sequence in context: A065232 A074170 A076543 this_sequence A064388 A064387 A064389

KEYWORD

easy,nonn,nice

AUTHOR

B. Recaman [Recam\'{a}n], njas, Simon Plouffe (plouffe(AT)math.uqam.ca)

EXTENSIONS

Allan Wilks (allan(AT)research.att.com), Nov 06, 2001, computed 10^15 terms of this sequence. At this point the smallest missing number is 852655.

After 10^25 terms of A005132 the smallest missing number is still 852655. - Benjamin Chaffin (chaffin(AT)gmail.com), Jun 13 2006

Even after 7.78e37 terms, the smallest missing number is still 852655. - Benjamin Chaffin (chaffin(AT)gmail.com), Mar 28 2008

page 1

Search completed in 0.004 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified May 8 18:01 EDT 2008. Contains 139605 sequences.


AT&T Labs Research