OFFSET
1,3
COMMENTS
The absolute value is relevant only when a(n) = 0, in which case a(n+1) = gcd(a(n), 2n+1) = 2n+1.
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.)
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
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.
a(2) = 0 therefore a(3) = gcd(0,2*2+1) = 5, which is prime.
a(3+5) = a(8) = 0 therefore a(9) = gcd(0,2*8+1) = 17, which is also prime.
a(9+17) = a(26) = 0 therefore a(27) = gcd(0,2*26+1) = 53, which is also prime.
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.
MATHEMATICA
nxt[{n_, a_}]:={n+1, Abs[a-GCD[a, 2n+1]]}; NestList[nxt, {1, 1}, 80][[All, 2]] (* Harvey P. Dale, Jan 17 2023 *)
PROG
(PARI) print1(a=1); for(n=1, 99, print1(", ", a=abs(a-gcd(a, 2*n+1))))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
M. F. Hasler, Aug 14 2015
STATUS
approved