login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A118201 Smallest difference such that both difference and number do not occur previously. 3
0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 44, 68, 93, 66, 38, 67, 37, 5, 36, 69, 35, 70, 34, 71, 33, 72, 32, 73, 31, 74, 30, 75, 29, 76, 28, 77, 27, 78, 26, 79, 133, 188, 132, 189, 131, 190, 130, 191, 129, 192, 128, 193, 127, 60, 134 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

Similar to Recamán's sequence (A005132), but increases the difference to avoid duplicating values. Conjecture that every nonnegative integer occurs in this sequence. Evaluating through n=20000, the smallest number that has not occurred is 139.

The first 14 terms appear in the original OEIS logo. - Philippe Deléham, Mar 01 2013

This is very similar to A064389, and arguably just as nice. - Franklin T. Adams-Watters, Nov 11 2015

LINKS

Alois P. Heinz, Table of n, a(n) for n = 0..20000

FORMULA

a(n+1) = a(n)-d or a(n)+d, where a(n+1) must be positive and must not have occurred previously in the sequence; choose the smallest positive d such that this is possible where d is not |a(m+1)-a(m)| for any m < n; if both a(n)-d and a(n)+d have not occurred, choose a(n)-d.

MAPLE

N:= 1000: # get all terms up to the first member > N

a[0]:= 0:

davail:= [$1..N]:

B:= Vector(2*N):

for n from 1 do

  found:= false;

  for i from 1 to nops(davail) do

    d:= davail[i];

    an:= a[n-1]-d;

    if an > 0 and B[an] = 0 then

      a[n]:= an; found:= true; break

    fi;

    ap:= a[n-1]+d;

    if B[ap] = 0 then

      a[n]:= ap; found:= true; break

    fi

  od:

  if (not found) or (a[n] > N) then break fi;

  davail:= subsop(i=NULL, davail);

  B[a[n]]:= 1;

od:

seq(a[i], i=0..n);  # Robert Israel, Nov 17 2015

MATHEMATICA

M = 1000; (* get all terms up to the first member > M *)

a[0] = 0;

davail = Range[M];

B = Array[0&, 2M];

For[n = 1, True, n++,

found = False;

For[i = 1, i <= Length[davail], i++,

d = davail[[i]];

an = a[n-1] - d;

If[an > 0 && B[[an]] == 0,

a[n] = an; found = True; Break[]

];

ap = a[n-1] + d;

If[B[[ap]] == 0,

a[n] = ap; found = True; Break[]

]

];

If [Not @ found || (a[n] > M), Break[]];

davail = ReplacePart[davail, i -> Nothing];

B[[a[n]]] = 1;

];

Table[a[i], {i, 0, n}] (* Jean-François Alcover, Oct 24 2016, translated from Robert Israel's Maple code *)

CROSSREFS

Cf. A118202 (inverse), A005132, A064389.

Sequence in context: A064388 A064387 A064389 * A274647 A113880 A171884

Adjacent sequences:  A118198 A118199 A118200 * A118202 A118203 A118204

KEYWORD

nonn,look,nice

AUTHOR

Franklin T. Adams-Watters, Apr 14 2006

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy .

Last modified August 16 11:10 EDT 2017. Contains 290623 sequences.