login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A254330 Define a(1)=19 and a(2)=29. Then, if a(n-2) and a(n-1) have the same parity, a(n) = (a(n-2) + a(n-1))/2; if not, a(n) = a(n-2)/2 + a(n-1) for a(n-2) even or a(n) = a(n-2) + a(n-1)/2 for a(n-1) even. 3
19, 29, 24, 41, 53, 47, 50, 72, 61, 97, 79, 88, 123, 167, 145, 156, 223, 301, 262, 432, 347, 563, 455, 509, 482, 750, 616, 683, 991, 837, 914, 1294, 1104, 1199, 1751, 1475, 1613, 1544, 2385, 3157, 2771, 2964, 4253, 5735, 4994, 8232, 6613, 10729, 8671, 9700 (list; graph; refs; listen; history; text; internal format)
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.
This sequence starts with the two smallest prime numbers that are not present in A254498; A254498 starts with the first two prime numbers 2,3.
LINKS
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
Cf. A254498.
Sequence in context: A166667 A121458 A268488 * A052260 A067833 A135170
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 28 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 06:57 EDT 2024. Contains 371265 sequences. (Running on oeis4.)