cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A078783 a(0) = 0; a(1)=1; for n>1, a(n) = least positive integer m not among a(1),...,a(n-1) such that |m-a(n-1)| > |a(n-1)-a(n-2)|.

This page as a plain text file.
%I A078783 #22 Oct 30 2022 18:19:59
%S A078783 0,1,3,6,2,7,13,4,14,25,5,26,48,8,49,91,9,92,176,10,177,345,11,346,
%T A078783 682,12,683,1355,15,1356,2698,16,2699,5383,17,5384,10752,18,10753,
%U A078783 21489,19,21490,42962,20,42963,85907,21,85908,171796,22,171797
%N A078783 a(0) = 0; a(1)=1; for n>1, a(n) = least positive integer m not among a(1),...,a(n-1) such that |m-a(n-1)| > |a(n-1)-a(n-2)|.
%C A078783 This is a permutation pi of the nonnegative integers such that |pi(n+1)-pi(n)| is strictly increasing. In other words, it is a walk on the nonnegative numbers with strictly increasing step size which visits every number exactly once.
%C A078783 A greedy version of Recamán's sequence: Construct two sequences a() and d() as follows. a(0)=0, a(1)=1, a(2)=3, d(0)=0, d(1)=1, d(2)=2. For n>=3, let m be smallest nonnegative number not yet in the a sequence. Let i = a(n-1)-m. If i > d(n), then a(n) = a(n-1)-i = m, d(n) = i; otherwise a(n) = a(n-1)+d(n-1)+1, d(n) = d(n-1)+1. Has the properties that a() is the Recamán transform of d() and every number appears in a(). This sequence is a(), while d() is A117073. Has a natural decompostion into segments of length 3. - _N. J. A. Sloane_, Apr 16 2006
%C A078783 For n>0: a(3*n-2)=A117070(n), a(3*n-1)=A117071(n) and a(3*n)=A117072(n).
%D A078783 N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.
%H A078783 Paul Tek, <a href="/A078783/b078783.txt">Table of n, a(n) for n = 0..2000</a>
%H A078783 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%t A078783 a[0] = 0; a[1] = 1;
%t A078783 a[n_] := a[n] = For[m = 2, True, m++, If[FreeQ[Array[a, n-1], m], If[Abs[m - a[n-1]] > Abs[a[n-1] - a[n-2]], Return[m]]]];
%t A078783 Table[a[n], {n, 0, 50}] (* _Jean-François Alcover_, Aug 02 2018 *)
%o A078783 (Haskell)
%o A078783 import Data.List (delete)
%o A078783 a078783 n = a078783_list !! n
%o A078783 (a078783_list, a117073_list) = unzip $
%o A078783    (0,0) : (1,1) : (3,2) : f 3 2 (2:[4..]) where
%o A078783    f a d ms@(m:_) = (a', d') : f a' d' (delete a' ms) where
%o A078783      (a', d') = if i > d then (m, i) else (a + d + 1, d + 1)
%o A078783      i = a - m
%o A078783 -- _Reinhard Zumkeller_, May 01 2015
%Y A078783 Cf. A072007, A005132, A117070-A117075.
%Y A078783 Cf. A257502 (inverse).
%K A078783 easy,nonn
%O A078783 0,3
%A A078783 _Reiner Martin_, Jan 09 2003