Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #23 Jan 17 2023 15:35:30
%S 1,0,5,4,3,2,1,0,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,53,52,51,
%T 50,49,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,
%U 21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,149,148,147,146,145,144,143
%N a(n+1) = abs(a(n) - gcd(a(n), 2n+1)), a(1) = 1.
%C The absolute value is relevant only when a(n) = 0, in which case a(n+1) = gcd(a(n), 2n+1) = 2n+1.
%C It is conjectured that for all n, a(n) = 0 implies that 2n+1 = a(n+1) is prime, cf. A186254. (This is the sequence {u(n)} mentioned there.)
%H Harvey P. Dale, <a href="/A261302/b261302.txt">Table of n, a(n) for n = 1..1000</a>
%e For n = 1, a(n) = 1 therefore a(n+1) = a(n) - gcd(a(n),2*n+1) = 1 - 1 = 0. The same is true for n = 7.
%e a(2) = 0 therefore a(3) = gcd(0,2*2+1) = 5, which is prime.
%e a(3+5) = a(8) = 0 therefore a(9) = gcd(0,2*8+1) = 17, which is also prime.
%e a(9+17) = a(26) = 0 therefore a(27) = gcd(0,2*26+1) = 53, which is also prime.
%e a(31) = 49 and 2*31+1 = 63, therefore a(32) = 49 - gcd(49,63) = 49 - 7 = 42. Note that for n = 31+49 = 80, 2n+1 = 161 would not be prime, but for n = 32+42 = 74, 2n+1 = 149 = a(75) is prime.
%t nxt[{n_,a_}]:={n+1,Abs[a-GCD[a,2n+1]]}; NestList[nxt,{1,1},80][[All,2]] (* _Harvey P. Dale_, Jan 17 2023 *)
%o (PARI) print1(a=1);for(n=1,99,print1(",",a=abs(a-gcd(a,2*n+1))))
%Y Cf. A261301 - A261310, A186253 - A186263, A106108.
%K nonn,easy
%O 1,3
%A _M. F. Hasler_, Aug 14 2015