OFFSET
1,1
COMMENTS
If we start with a(1)=19 and a(2)=19, then a(n)=19 for every n.
As N increases, Sum_{n=1..N} 1/a(n) converges quickly to
0.3461955119388269653531110943666276404231513450...
More generally, if one starts with a(1) = a(2), then a(n) = a(1) for every n.
LINKS
Pierre CAMI, Table of n, a(n) for n = 1..1000
EXAMPLE
As 19 and 29 are both odd, a(3) = (19 + 29)/2 = 24.
As 29 is odd and 24 is even, a(4) = 29 + 24/2 = 41.
MATHEMATICA
a[n_] := a[n] = If[ Mod[ a[n-1], 2] == Mod[ a[n-2], 2], (a[n-1] + a[n-2])/2, If[ OddQ@ a[n-1], a[n-1] + a[n-2]/2, a[n-1]/2 + a[n-2]]]; a[1] = 3; a[2] = 5; Array[a, 70] (* Robert G. Wilson v, Mar 11 2015 *)
nxt[{a_, b_}]:={b, Which[IntegerQ[(a+b)/2], (a+b)/2, EvenQ[a], a/2+b, True, a+b/2]}; NestList[nxt, {19, 29}, 50][[All, 1]] (* Harvey P. Dale, Mar 09 2019 *)
PROG
(PFGW & SCRIPT)
SCRIPT
DIM i, 19
DIM j, 29
DIM k
DIM n, 2
OPENFILEOUT myf, seq.txt
WRITE myf, i
WRITE myf, j
LABEL loop1
SET n, n+1
IF n>1000 THEN END
IF i%2==0 && j%2==0 THEN SET k, (i+j)/2
IF i%2==1 && j%2==1 THEN SET k, (i+j)/2
IF i%2==0 && j%2==1 THEN SET k, i/2+j
IF i%2==1 && j%2==0 THEN SET k, i+j/2
WRITE myf, k
SET i, j
SET j, k
GOTO loop1
(PARI) a(n, a=19, b=29)={n||return(a); for(i=2, n, b=if((b-a)%2, if(a%2, a+(a=b)\2, a\2+a=b), (a+a=b)\2)); b} \\ M. F. Hasler, Feb 10 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 28 2015
STATUS
approved