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!)
A254498 Define a(1)=2 and a(2)=3. 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
2, 3, 4, 5, 7, 6, 10, 8, 9, 13, 11, 12, 17, 23, 20, 33, 43, 38, 62, 50, 56, 53, 81, 67, 74, 104, 89, 141, 115, 128, 179, 243, 211, 227, 219, 223, 221, 222, 332, 277, 443, 360, 623, 803, 713, 758, 1092, 925, 1471, 1198, 2070, 1634, 1852, 1743, 2669, 2206, 3772 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

If we start with a(1)=a(2)=2, then a(n)=2 for every n.

As N increases, sum_{n=1..N} 1/a(n) converges quickly to

2.6332482094949767034995557279162460374965915768...

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 2 is even and 3 is odd, a(4) = 2/2 + 3 = 4.

As 3 is odd and 4 is even, a(5) = 3 + 4/2 = 5.

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] = 2; a[2] = 3; a = Array[a, 69] (* Robert G. Wilson v, Mar 11 2015 *)

PROG

(PFGW & SCRIPT)

SCRIPT

DIM i, 0

DIM j, 4

DIM k

DIM n, 1

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=0, b=4)={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. A254330.

Sequence in context: A256231 A288870 A283194 * A185969 A266637 A278505

Adjacent sequences: A254495 A254496 A254497 * A254499 A254500 A254501

KEYWORD

nonn

AUTHOR

Pierre CAMI, Jan 31 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 26 06:47 EDT 2023. Contains 361529 sequences. (Running on oeis4.)