login
A variation on Recamán's sequence (A005132): a(n) is the first positive number of the form a(n-1)-n*k, k>0 not already in the sequence; and if no such number exists, then a(n) is the first number of the form a(n-1)+n*k, k>0 not already in the sequence.
3

%I #20 Dec 28 2018 14:01:00

%S 0,1,3,6,2,7,13,20,12,21,11,22,10,23,9,24,8,25,43,5,45,66,44,67,19,69,

%T 17,71,15,73,103,72,40,106,38,108,36,110,34,112,32,114,30,116,28,118,

%U 26,120,168,119,169,16,68,121,175,65,177,63,179,61,181,59,183

%N A variation on Recamán's sequence (A005132): a(n) is the first positive number of the form a(n-1)-n*k, k>0 not already in the sequence; and if no such number exists, then a(n) is the first number of the form a(n-1)+n*k, k>0 not already in the sequence.

%C Is this a permutation of the natural numbers?

%C The inverse is: 0, 1, 4, 2, 164, 19, 3, 5, 16, 14, 12, 10, 8, 6, 8228, 28, 51, 26, 158, 24, 7, 9, 11, 13, 15, 17, 46, 90, ..., . _Robert G. Wilson v_, Sep 07 2016

%C After 3.2*10^11 terms, the smallest number which has not appeared is 154. - _Benjamin Chaffin_, Oct 05 2016

%H Robert G. Wilson v, <a href="/A274648/b274648.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>

%t f[s_List] := Block[{k = 1, l = s[[-1]], n = Length@ s}, While[ MemberQ[s, l - k*n] && l > k*n, k++]; If[l > k*n, Append[s, l - k*n], k = 1; While[ MemberQ[s, l + k*n], k++]; Append[s, l + k*n]]]; Nest[f, {0}, 60] (* _Robert G. Wilson v_, Sep 07 2016 *)

%Y Cf. A273148 (inverse), A005132, A274647 (another variant).

%K nonn

%O 0,3

%A _Max Barrentine_, Aug 12 2016