Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A119387
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
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
1
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; listen)
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.

PROGRAM

(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: A127969 A081733 A102587 this_sequence A055941 A068076 A138498

Adjacent sequences: A119384 A119385 A119386 this_sequence A119388 A119389 A119390

KEYWORD

easy,nonn

AUTHOR

Leroy Quet (qq-quet(AT)mindspring.com), Jul 26 2006

EXTENSIONS

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

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified July 26 13:41 EDT 2008. Contains 142293 sequences.


AT&T Labs Research