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!)
A239907 Let cn(n,k) denote the number of times 11..1 (k 1's) appears in the binary representation of n; a(n) = n - cn(n,1) + cn(n,2) - cn(n,3) + cn(n,4) - ... . 4
0, 0, 1, 2, 3, 3, 5, 5, 7, 7, 8, 9, 11, 11, 12, 13, 15, 15, 16, 17, 18, 18, 20, 20, 23, 23, 24, 25, 26, 26, 28, 28, 31, 31, 32, 33, 34, 34, 36, 36, 38, 38, 39, 40, 42, 42, 43, 44, 47, 47, 48, 49, 50, 50, 52, 52, 54, 54, 55, 56, 58, 58, 59, 60, 63, 63, 64, 65, 66, 66, 68, 68, 70, 70, 71, 72, 74, 74, 75 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
LINKS
Jon Maiga, Computer-generated formulas for A239907, Sequence Machine.
FORMULA
Conjecture: a(n) = n - A329320(n) for n >= 0 (noticed by Sequence Machine). - Mikhail Kurkov, Oct 13 2021
MAPLE
# From A014081:
cn := proc(v, k) local n, s, nn, i, j, som, kk;
som := 0;
kk := convert(cat(seq(1, j = 1 .. k)), string);
n := convert(v, binary);
s := convert(n, string);
nn := length(s);
for i to nn - k + 1 do
if substring(s, i .. i + k - 1) = kk then som := som + 1 fi od;
som; end;
g:=n->add((-1)^i*cn(n, i), i=1..10); # assumes n < 1023
[seq(n+g(n), n=0..100)];
MATHEMATICA
cn[n_, k_] := Count[Partition[IntegerDigits[n, 2], k, 1], Table[1, {k}]]; Table[n - Sum[cn[n, i], {i, 1, IntegerLength[n, 2], 2}] + Sum[cn[n, i], {i, 2, IntegerLength[n, 2], 2}], {n, 0, 78}] (* Michael De Vlieger, Sep 18 2015 *)
PROG
(PARI)
binruns(n) = {
if (n == 0, return([1, 0]));
my(bag = List(), v=0);
while(n != 0,
v = valuation(n, 2); listput(bag, v); n >>= v; n++;
v = valuation(n, 2); listput(bag, v); n >>= v; n--);
return(Vec(bag));
};
a(n) = {
my(v = binruns(n));
n - sum(i = 1, #v, if (i%2 == 0, (v[i] + 1)\2, 0))
};
vector(79, i, a(i-1)) \\ Gheorghe Coserea, Sep 18 2015
CROSSREFS
Sequence in context: A283313 A091937 A239906 * A113637 A257539 A159050
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Apr 07 2014
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 August 14 11:50 EDT 2024. Contains 375159 sequences. (Running on oeis4.)