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!)
A304111 Partial sums of f(n) = (-1)^(1-A304109(n)). 4
0, 1, 2, 3, 2, 1, 2, 3, 2, 3, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 4, 3, 2, 3, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 3, 2, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 2, 3, 2, 1, 2, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 4, 3, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
Start from the initial value a(0) = 0, after which, for n > 0, each successive term a(n) is either one more or one less than the previous term a(n-1), depending on whether the binary expansion of n encodes a squarefree (0,1)-polynomial when the factorization is done in polynomial ring GF(2)[X]], or whether it encodes a polynomial where at least one of its irreducible divisors occurs more than once.
The first negative term occurs as a(153) = -1. See also comments at A304010.
LINKS
FORMULA
a(0) = 0, and for n > 0, a(n) = a(n-1) + (-1)^(1-A304109(n)).
For n >= 1, a(n) = (2*A304110(n)) - n.
PROG
(PARI)
up_to = 128;
A304109(n) = { my(fm=factor(Pol(binary(n))*Mod(1, 2))); for(k=1, #fm~, if(fm[k, 2] > 1, return(0))); (1); };
prepare_v304110(up_to) = { my(v=vector(up_to), c=0); for(n=1, up_to, c += A304109(n); v[n] = c); (v); };
v304110 = prepare_v304110(up_to);
A304110(n) = v304110[n];
A304111(n) = ((2*A304110(n)) - n);
\\ Or just as:
c=0; for(n=0, up_to, if(n>0, c+=((-1)^(1-A304109(n)))); print1(c, ", "));
CROSSREFS
Sequence in context: A277745 A353497 A320858 * A030314 A269624 A098236
KEYWORD
sign
AUTHOR
Antti Karttunen, May 13 2018
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 17 00:41 EDT 2024. Contains 375198 sequences. (Running on oeis4.)