login
This site is supported by donations to The OEIS Foundation.
Logo

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A119387 a(n) = number of binary digits (1's and nonleading 0's) which remain unchanged in their positions when n and (n+1) are written in binary. 0
0, 0, 1, 0, 2, 1, 2, 0, 3, 2, 3, 1, 3, 2, 3, 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4, 0, 5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 1, 5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 0, 6, 5, 6, 4, 6, 5, 6, 3, 6, 5, 6, 4, 6, 5, 6, 2, 6, 5, 6, 4, 6, 5, 6, 3, 6, 5, 6, 4, 6, 5, 6, 1, 6, 5, 6, 4, 6, 5, 6, 3, 6 (list; graph; refs; listen; history; internal format)
OFFSET

0,5

FORMULA

a(n) = A048881(n) + A086784(n+1). (A048881(n) is the number of 1's which remain unchanged between binary n and (n+1). A086784(n+1) is the number of nonleading 0's which remain unchanged between binary n and (n+1).)

a(A000225(n))=0. - R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Jul 29 2006

EXAMPLE

9 in binary is 1001. 10 (decimal) is 1010 in binary. 2 binary digits remain unchanged (the leftmost two digits) between 1001 and 1010. So a(9) = 2.

PROG

(C) #include <stdio.h> #define NMAX 200 int sameD(int a, int b) { int resul=0 ; while(a>0 && b >0) { if( (a &1) == (b & 1)) resul++ ; a >>= 1 ; b >>= 1 ; } return resul ; } int main(int argc, char*argv[]) { for(int n=0; n<NMAX; n++) printf("%d, ", sameD(n, n+1)) ; return 0 ; } - R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Jul 29 2006

CROSSREFS

Cf. A048881, A086784.

Sequence in context: A159834 A177995 A147786 * A055941 A068076 A138498

Adjacent sequences:  A119384 A119385 A119386 * A119388 A119389 A119390

KEYWORD

easy,nonn,base

AUTHOR

Leroy Quet, Jul 26 2006

EXTENSIONS

More terms from R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Jul 29 2006

Edited by Charles R Greathouse IV (charles.greathouse(AT)case.edu), Aug 04 2010

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
Recent Additions | More pages | Superseeker | Maintained by The OEIS Foundation Inc.

Content is available under The OEIS End-User License Agreement .

Last modified February 14 20:38 EST 2012. Contains 205663 sequences.