cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 25 results. Next

A209229 Characteristic function of powers of 2, cf. A000079.

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Reinhard Zumkeller, Mar 06 2012

Keywords

Comments

Essentially the same as A036987 (the Fredholm-Rueppel sequence).
Completely multiplicative with a(2^e) = 1, a(p^e) = 0 for odd primes p. - Mitch Harris, Apr 19 2005
Moebius transform of A001511. - R. J. Mathar, Jun 20 2014

Examples

			x + x^2 + x^4 + x^8 + x^16 + x^32 + x^64 + x^128 + x^256 + x^512 + x^1024 + ...
		

References

  • Michel Dekking, Michel Mendes France and Alf van der Poorten, "Folds", The Mathematical Intelligencer, Vol. 4, No. 3 (1982), pp. 130-138 & front cover, and Vol. 4, No. 4 (1982), pp. 173-181 (printed in two parts).
  • Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.

Crossrefs

Cf. A001511, A029837 (partial sums), A087003 (moebius transform), A090678, A104977, A154955 (Dirichlet inverse).

Programs

  • C
    int a (unsigned long n) { return n & !(n & (n-1)); } /* Charles R Greathouse IV, Sep 15 2012 */
    
  • Haskell
    a209229 n | n < 2 = n
              | n > 1 = if m > 0 then 0 else a209229 n'
              where (n',m) = divMod n 2
    
  • Maple
    A209229 := proc(n)
        if n <= 0 then
            0 ;
        elif n = 1 then
            1;
        elif type (n,'odd') or A001221(n) > 1 then
            0 ;
        else
            1;
        end if;
    end proc:
    seq(A209229(n),n=0..40) ; # R. J. Mathar, Jan 07 2021
  • Mathematica
    a[n_] := Boole[n == 2^IntegerExponent[n, 2]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, May 06 2014 *)
    Table[If[IntegerQ[Log[2,n]],1,0],{n,0,100}] (* Harvey P. Dale, Jun 24 2018 *)
  • PARI
    a(n)=n==1<Charles R Greathouse IV, Mar 07 2012
    
  • PARI
    {a(n) = if( n<2 || n%2, n==1, isprimepower(n) > 0)} \\ Michael Somos, Jan 03 2013
    
  • Python
    def A209229(n): return int(not(n&-n)^n) if n else 0 # Chai Wah Wu, Jul 08 2022

Formula

a(A000079(n)) = 1; a(A057716(n)) = 0.
a(n+1) = A036987(n).
a(n) = if n < 2 then n else (if n is even then a(n/2) else 0).
The generating function g(x) satisfies g(x) - g(x^2) = x. - Joerg Arndt, May 11 2010
Dirichlet g.f.: 1/(1 - 2^(-s)). - R. J. Mathar, Mar 07 2012
G.f.: x / (1 - x / (1 + x / (1 + x / (1 - x / (1 + x / (1 - x / ...)))))) = x / (1 + b(1) * x / (1 + b(2) * x / (1 + b(3) * x / ...))) where b(n) = (-1)^ A090678(n+1). - Michael Somos, Jan 03 2013
With a(0) = 0 removed is convolution inverse of A104977. - Michael Somos, Jan 03 2013
From Antti Karttunen, Nov 19 2017: (Start)
a(n) = abs(A154269(n)).
For n > 1, a(n) = A069517(n)/2 = 2 - A201219(n). (End)
a(n) = A048298(n)/n. - R. J. Mathar, Jan 07 2021
a(n) = floor((2^n)/n) - floor((2^n - 1)/n), for n>=1. - Ridouane Oudra, Oct 15 2021

A048272 Number of odd divisors of n minus number of even divisors of n.

Original entry on oeis.org

1, 0, 2, -1, 2, 0, 2, -2, 3, 0, 2, -2, 2, 0, 4, -3, 2, 0, 2, -2, 4, 0, 2, -4, 3, 0, 4, -2, 2, 0, 2, -4, 4, 0, 4, -3, 2, 0, 4, -4, 2, 0, 2, -2, 6, 0, 2, -6, 3, 0, 4, -2, 2, 0, 4, -4, 4, 0, 2, -4, 2, 0, 6, -5, 4, 0, 2, -2, 4, 0, 2, -6, 2, 0, 6, -2, 4, 0, 2, -6, 5, 0, 2, -4, 4, 0, 4, -4, 2, 0, 4, -2, 4
Offset: 1

Views

Author

Keywords

Comments

abs(a(n)) = (1/2) * (number of pairs (i,j) satisfying n = i^2 - j^2 and -n <= i,j <= n). - Benoit Cloitre, Jun 14 2003
As A001227(n) is the number of ways to write n as the difference of 3-gonal numbers, a(n) describes the number of ways to write n as the difference of e-gonal numbers for e in {0,1,4,8}. If pe(n):=(1/2)*n*((e-2)*n+(4-e)) is the n-th e-gonal number, then 4*a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e=1, 2*a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e in {0,4} and for a(n) itself is a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e=8. (Same for e=-1 see A035218.) - Volker Schmitt (clamsi(AT)gmx.net), Nov 09 2004
An argument by Gareth McCaughan suggests that the average of this sequence is log(2). - Hans Havermann, Feb 10 2013 [Supported by a graph. - Vaclav Kotesovec, Mar 01 2023]
From Keith F. Lynch, Jan 20 2024: (Start)
a(n) takes every possible integer value, positive, negative, and zero. Proof: For all nonnegative integers k, a(3^k) = 1+k, a(2^k) = 1-k.
a(n) takes every possible integer value except 1 and -1 infinitely many times. Proof: a(o^(k-1)) = k and a(4*o^(k-1)) = -k for all positive integers k and odd primes o, of which there are infinitely many. a(n) = 0 iff n = 2 (mod 4). a(n) = 1 iff n = 1. a(n) = -1 iff n = 4.
a(n) takes prime value p only for n = o^(p-1), where o is any odd prime.
Terms have a simple pattern that repeats with a period of 4: Positive, zero, positive, negative.
(End)
Inverse Möbius transform of (-1)^(n+1). - Wesley Ivan Hurt, Jun 22 2024

Examples

			a(20) = -2 because 20 = 2^2*5^1 and (1-2)*(1+1) = -2.
G.f. = x + 2*x^3 - x^4 + 2*x^5 + 2*x^7 - 2*x^8 + 3*x^9 + 2*x^11 - 2*x^12 + ...
		

References

  • Louis Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16, (6), first formula.
  • S. Ramanujan, Notebooks, Tata Institute of Fundamental Research, Bombay 1957 Vol. 1, see page 97, 7(ii).

Crossrefs

Cf. A048298. A diagonal of A060184.
First differences of A059851.
Indices of records: A053624 (highs), A369151 (lows).

Programs

  • Haskell
    a048272 n = a001227 n - a183063 n  -- Reinhard Zumkeller, Jan 21 2012
    
  • Magma
    [&+[(-1)^(d+1):d in Divisors(n)] :n in [1..95] ]; // Marius A. Burtea, Aug 10 2019
  • Maple
    add(x^n/(1+x^n), n=1..60): series(%,x,59);
    A048272 := proc(n)
        local a;
        a := 1 ;
        for pfac in ifactors(n)[2] do
            if pfac[1] = 2 then
                a := a*(1-pfac[2]) ;
            else
                a := a*(pfac[2]+1) ;
            end if;
        end do:
        a ;
    end proc: # Schmitt, sign corrected R. J. Mathar, Jun 18 2016
    # alternative Maple program:
    a:= n-> -add((-1)^d, d=numtheory[divisors](n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 28 2018
  • Mathematica
    Rest[ CoefficientList[ Series[ Sum[x^k/(1 - (-x)^k), {k, 111}], {x, 0, 110}], x]] (* Robert G. Wilson v, Sep 20 2005 *)
    dif[n_]:=Module[{divs=Divisors[n]},Count[divs,?OddQ]-Count[ divs, ?EvenQ]]; Array[dif,100] (* Harvey P. Dale, Aug 21 2011 *)
    a[n]:=Sum[-(-1)^d,{d,Divisors[n]}] (* Steven Foster Clark, May 04 2018 *)
    f[p_, e_] := If[p == 2, 1 - e, 1 + e]; a[n_] := Times @@ f @@@ FactorInteger[n]; a[1] = 1; Array[a, 100] (* Amiram Eldar, Jun 09 2022 *)
  • PARI
    {a(n) = if( n<1, 0, -sumdiv(n, d, (-1)^d))}; /* Michael Somos, Jul 22 2006 */
    
  • PARI
    N=17; default(seriesprecision,N); x=z+O(z^(N+1))
    c=sum(j=1,N,j*x^j); \\ log case
    s=-log(prod(j=1,N,(1+x^j)^(1/j)));
    s=serconvol(s,c)
    v=Vec(s) \\ Joerg Arndt, May 03 2008
    
  • PARI
    a(n)=my(o=valuation(n,2),f=factor(n>>o)[,2]);(1-o)*prod(i=1,#f,f[i]+1) \\ Charles R Greathouse IV, Feb 10 2013
    
  • PARI
    a(n)=direuler(p=1,n,if(p==2,(1-2*X)/(1-X)^2,1/(1-X)^2))[n] /* Ralf Stephan, Mar 27 2015 */
    
  • PARI
    {a(n) = my(d = n -> if(frac(n), 0, numdiv(n))); if( n<1, 0, if( n%4, 1, -1) * (d(n) - 2*d(n/2) + 2*d(n/4)))}; /* Michael Somos, Aug 11 2017 */
    

Formula

Coefficients in expansion of Sum_{n >= 1} x^n/(1+x^n) = Sum_{n >= 1} (-1)^(n-1)*x^n/(1-x^n). Expand Sum 1/(1+x^n) in powers of 1/x.
If n = 2^p1*3^p2*5^p3*7^p4*11^p5*..., a(n) = (1-p1)*Product_{i>=2} (1+p_i).
Multiplicative with a(2^e) = 1 - e and a(p^e) = 1 + e if p > 2. - Vladeta Jovovic, Jan 27 2002
a(n) = (-1)*Sum_{d|n} (-1)^d. - Benoit Cloitre, May 12 2003
Moebius transform is period 2 sequence [1, -1, ...]. - Michael Somos, Jul 22 2006
G.f.: Sum_{k>0} -(-1)^k * x^(k^2) * (1 + x^(2*k)) / (1 - x^(2*k)) [Ramanujan]. - Michael Somos, Jul 22 2006
Equals A051731 * [1, -1, 1, -1, 1, ...]. - Gary W. Adamson, Nov 07 2007
From Reinhard Zumkeller, Jan 21 2012: (Start)
a(n) = A001227(n) - A183063(n).
a(A008586(n)) < 0; a(A005843(n)) <= 0; a(A016825(n)) = 0; a(A042968(n)) >= 0; a(A005408(n)) > 0. (End)
a(n) = Sum_{k=0..n} A081362(k)*A015723(n-k). - Mircea Merca, Feb 26 2014
abs(a(n)) = A112329(n) = A094572(n) / 2. - Ray Chandler, Aug 23 2014
From Peter Bala, Jan 07 2015: (Start)
Logarithmic g.f.: log( Product_{n >= 1} (1 + x^n)^(1/n) ) = Sum_{n >= 1} a(n)*x^n/n.
a(n) = A001227(n) - A183063(n). By considering the logarithmic generating functions of these three sequences we obtain the identity
( Product_{n >= 0} (1 - x^(2*n+1))^(1/(2*n+1)) )^2 = Product_{n >= 1} ( (1 - x^n)/(1 + x^n) )^(1/n). (End)
Dirichlet g.f.: zeta(s)*eta(s) = zeta(s)^2*(1-2^(-s+1)). - Ralf Stephan, Mar 27 2015
a(2*n - 1) = A099774(n). - Michael Somos, Aug 12 2017
From Paul D. Hanna, Aug 10 2019: (Start)
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) - x^k)^(n-k) = Sum_{n>=0} a(n)*x^(2*n).
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) + x^k)^(n-k) * (-1)^k = Sum_{n>=0} a(n)*x^(2*n). (End)
a(n) = 2*A000005(2n) - 3*A000005(n). - Ridouane Oudra, Oct 15 2019
Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k)/A000005(k) = 2*log(2)-1. - Amiram Eldar, Mar 01 2023

Extensions

New definition from Vladeta Jovovic, Jan 27 2002

A038712 Let k be the exponent of highest power of 2 dividing n (A007814); a(n) = 2^(k+1)-1.

Original entry on oeis.org

1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 31, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 63, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 31, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 127, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 31, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 63, 1, 3
Offset: 1

Views

Author

Henry Bottomley, May 02 2000

Keywords

Comments

n XOR n-1, i.e., nim-sum of a pair of consecutive numbers.
Denominator of quotient sigma(2*n)/sigma(n). - Labos Elemer, Nov 04 2003
a(n) = the Towers of Hanoi disc moved at the n-th move, using standard moves with discs labeled (1, 3, 7, 15, ...) starting from top (smallest = 1). - Gary W. Adamson, Oct 26 2009
Equals row sums of triangle A168312. - Gary W. Adamson, Nov 22 2009
In the binary expansion of n, delete everything left of the rightmost 1 bit, and set all bits to the right of it. - Ralf Stephan, Aug 22 2013
Every finite sequence of positive integers summing to n may be termwise dominated by a subsequence of the first n values in this sequence [see Bannister et al., 2013]. - David Eppstein, Aug 31 2013
Sum of powers of 2 dividing n. - Omar E. Pol, Aug 18 2019
Given the binary expansion of (n-1) as {b[k-1], b[k-2], ..., b[2], b[1], b[0]}, then the binary expansion of a(n) is {bitand(b[k-1], b[k-2], ..., b[2], b[1], b[0]), bitand(b[k-2], ..., b[2], b[1], b[0]), ..., bitand(b[2], b[1], b[0]), bitand(b[1], b[0]), b[0], 1}. Recursively stated - 0th bit (L.S.B) of a(n), a(n)[0] = 1, a(n)[i] = bitand(a(n)[i-1], (n-1)[i-1]), where n[i] = i-th bit in the binary expansion of n. - Chinmaya Dash, Jun 27 2020

Examples

			a(6) = 3 because 110 XOR 101 = 11 base 2 = 3.
From _Omar E. Pol_, Aug 18 2019: (Start)
Illustration of initial terms:
a(n) is also the area of the n-th region of an infinite diagram of compositions (ordered partitions) of the positive integers, where the length of the n-th horizontal line segment is equal to A001511(n) and the length of the n-th vertical line segment is equal to A006519(n), as shown below (first eight regions):
-----------------------------
n    a(n)    Diagram
-----------------------------
.            _ _ _ _
1     1     |_| | | |
2     3     |_ _| | |
3     1     |_|   | |
4     7     |_ _ _| |
5     1     |_| |   |
6     3     |_ _|   |
7     1     |_|     |
8    15     |_ _ _ _|
.
The above diagram represents the eight compositions of 4: [1,1,1,1],[2,1,1],[1,2,1],[3,1],[1,1,2],[2,2],[1,3],[4].
(End)
		

Crossrefs

A038713 translated from binary, diagonals of A003987 on either side of main diagonal.
Cf. A062383. Partial sums give A080277.
Bisection of A089312. Cf. A088837.
a(n)-1 is exponent of 2 in A089893(n).
Cf. A130093.
This is Guy Steele's sequence GS(6, 2) (see A135416).
Cf. A001620, A168312, A220466, A361019 (Dirichlet inverse).

Programs

  • C
    int a(int n) { return n ^ (n-1); } // Russ Cox, May 15 2007
    
  • Haskell
    import Data.Bits (xor)
    a038712 n = n `xor` (n - 1) :: Integer  -- Reinhard Zumkeller, Apr 23 2012
    
  • Maple
    nmax:=98: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := 2^(p+1)-1 od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Feb 01 2013
    # second Maple program:
    a:= n-> Bits[Xor](n, n-1):
    seq(a(n), n=1..98);  # Alois P. Heinz, Feb 02 2023
  • Mathematica
    Table[Denominator[DivisorSigma[1, 2*n]/DivisorSigma[1, n]], {n, 1, 128}]
    Table[BitXor[(n + 1), n], {n, 0, 100}] (* Vladimir Joseph Stephan Orlovsky, Jul 19 2011 *)
  • PARI
    vector(66,n,bitxor(n-1,n)) \\ Joerg Arndt, Sep 01 2013; corrected by Michel Marcus, Aug 02 2018
    
  • PARI
    A038712(n) = ((1<<(1+valuation(n,2)))-1); \\ Antti Karttunen, Nov 24 2024
    
  • Python
    def A038712(n): return n^(n-1) # Chai Wah Wu, Jul 05 2022

Formula

a(n) = A110654(n-1) XOR A008619(n). - Reinhard Zumkeller, Feb 05 2007
a(n) = 2^A001511(n) - 1 = 2*A006519(n) - 1 = 2^(A007814(n)+1) - 1.
Multiplicative with a(2^e) = 2^(e+1)-1, a(p^e) = 1, p > 2. - Vladeta Jovovic, Nov 06 2001; corrected by Jianing Song, Aug 03 2018
Sum_{n>0} a(n)*x^n/(1+x^n) = Sum_{n>0} x^n/(1-x^n). Inverse Moebius transform of A048298. - Vladeta Jovovic, Jan 02 2003
From Ralf Stephan, Jun 15 2003: (Start)
G.f.: Sum_{k>=0} 2^k*x^2^k/(1 - x^2^k).
a(2*n+1) = 1, a(2*n) = 2*a(n)+1. (End)
Equals A130093 * [1, 2, 3, ...]. - Gary W. Adamson, May 13 2007
Sum_{i=1..n} (-1)^A000120(n-i)*a(i) = (-1)^(A000120(n)-1)*n. - Vladimir Shevelev, Mar 17 2009
Dirichlet g.f.: zeta(s)/(1 - 2^(1-s)). - R. J. Mathar, Mar 10 2011
a(n) = A086799(2*n) - 2*n. - Reinhard Zumkeller, Aug 07 2011
a((2*n-1)*2^p) = 2^(p+1)-1, p >= 0. - Johannes W. Meijer, Feb 01 2013
a(n) = A000225(A001511(n)). - Omar E. Pol, Aug 31 2013
a(n) = A000203(n)/A000593(n). - Ivan N. Ianakiev and Omar E. Pol, Dec 14 2017
L.g.f.: -log(Product_{k>=0} (1 - x^(2^k))) = Sum_{n>=1} a(n)*x^n/n. - Ilya Gutkovskiy, Mar 15 2018
a(n) = 2^(1 + (A183063(n)/A001227(n))) - 1. - Omar E. Pol, Nov 06 2018
a(n) = sigma(n)/(sigma(2*n) - 2*sigma(n)) = 3*sigma(n)/(sigma(4*n) - 4*sigma(n)) = 7*sigma(n)/(sigma(8*n) - 8*sigma(n)), where sigma(n) = A000203(n). - Peter Bala, Jun 10 2022
Sum_{k=1..n} a(k) ~ n*log_2(n) + (1/2 + (gamma - 1)/log(2))*n, where gamma is Euler's constant (A001620). - Amiram Eldar, Nov 24 2022
a(n) = Sum_{d divides n} m(d)*phi(d), where m(n) = Sum_{d divides n} (-1)^(d+1)* mobius(d). - Peter Bala, Jan 23 2024

Extensions

Definition corrected by N. J. A. Sloane, Sep 07 2015 at the suggestion of Marc LeBrun
Name corrected by Wolfdieter Lang, Aug 30 2016

A135416 a(n) = A036987(n)*(n+1)/2.

Original entry on oeis.org

1, 0, 2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

Guy Steele defines a family of 36 integer sequences, denoted here by GS(i,j) for 1 <= i, j <= 6, as follows. a[1]=1; a[2n] = i-th term of {0,1,a[n],a[n]+1,2a[n],2a[n]+1}; a[2n+1] = j-th term of {0,1,a[n],a[n]+1,2a[n],2a[n]+1}. The present sequence is GS(1,5).
The full list of 36 sequences:
GS(1,1) = A000007
GS(1,2) = A000035
GS(1,3) = A036987
GS(1,4) = A007814
GS(1,5) = A135416 (the present sequence)
GS(1,6) = A135481
GS(2,1) = A135528
GS(2,2) = A000012
GS(2,3) = A000012
GS(2,4) = A091090
GS(2,5) = A135517
GS(2,6) = A135521
GS(3,1) = A036987
GS(3,2) = A000012
GS(3,3) = A000012
GS(3,4) = A000120
GS(3,5) = A048896
GS(3,6) = A038573
GS(4,1) = A135523
GS(4,2) = A001511
GS(4,3) = A008687
GS(4,4) = A070939
GS(4,5) = A135529
GS(4,6) = A135533
GS(5,1) = A048298
GS(5,2) = A006519
GS(5,3) = A080100
GS(5,4) = A087808
GS(5,5) = A053644
GS(5,6) = A000027
GS(6,1) = A135534
GS(6,2) = A038712
GS(6,3) = A135540
GS(6,4) = A135542
GS(6,5) = A054429
GS(6,6) = A003817
(with a(0)=1): Moebius transform of A038712.

Crossrefs

Equals A048298(n+1)/2. Cf. A036987, A182660.

Programs

  • Maple
    GS:=proc(i,j,M) local a,n; a:=array(1..2*M+1); a[1]:=1;
    for n from 1 to M do
    a[2*n] :=[0,1,a[n],a[n]+1,2*a[n],2*a[n]+1][i];
    a[2*n+1]:=[0,1,a[n],a[n]+1,2*a[n],2*a[n]+1][j];
    od: a:=convert(a,list); RETURN(a); end;
    GS(1,5,200):
  • Mathematica
    i = 1; j = 5; Clear[a]; a[1] = 1; a[n_?EvenQ] := a[n] = {0, 1, a[n/2], a[n/2]+1, 2*a[n/2], 2*a[n/2]+1}[[i]]; a[n_?OddQ] := a[n] = {0, 1, a[(n-1)/2], a[(n-1)/2]+1, 2*a[(n-1)/2], 2*a[(n-1)/2]+1}[[j]]; Array[a, 105] (* Jean-François Alcover, Sep 12 2013 *)
  • PARI
    A048298(n) = if(!n,0,if(!bitand(n,n-1),n,0));
    A135416(n) = (A048298(n+1)/2); \\ Antti Karttunen, Jul 22 2018
    
  • Python
    def A135416(n): return int(not(n&(n+1)))*(n+1)>>1 # Chai Wah Wu, Jul 06 2022

Formula

G.f.: sum{k>=1, 2^(k-1)*x^(2^k-1) }.
Recurrence: a(2n+1) = 2a(n), a(2n) = 0, starting a(1) = 1.

Extensions

Formulae and comments by Ralf Stephan, Jun 20 2014

A067856 Sum_{n >= 1} a(n)/n^s = 1/(Sum_{n >= 1} (-1)^(n + 1)/n^s).

Original entry on oeis.org

1, 1, -1, 2, -1, -1, -1, 4, 0, -1, -1, -2, -1, -1, 1, 8, -1, 0, -1, -2, 1, -1, -1, -4, 0, -1, 0, -2, -1, 1, -1, 16, 1, -1, 1, 0, -1, -1, 1, -4, -1, 1, -1, -2, 0, -1, -1, -8, 0, 0, 1, -2, -1, 0, 1, -4, 1, -1, -1, 2, -1, -1, 0, 32, 1, 1, -1, -2, 1, 1, -1, 0, -1, -1, 0, -2, 1, 1, -1, -8, 0, -1, -1, 2, 1, -1, 1, -4, -1, 0, 1, -2, 1, -1, 1, -16, -1, 0, 0, 0
Offset: 1

Views

Author

Leroy Quet, Feb 15 2002

Keywords

Comments

Dirichlet inverse of A062157. - R. J. Mathar, Jul 15 2010
The first 31 terms equal the values of the Ramanujan sum c_n(8) -- see for example A085906 -- but a(32) <> c_{32}(8). - R. J. Mathar, Apr 02 2011
From Peter Bala, Mar 12 2019: (Start)
Let Mu(n) = (-1)^(n+1)*a(n), an analog of the Möbius function mu(n). Then for arithmetic functions f(n) and g(n) we have the following analog of the Möbius inversion formula: f(n) = Sum_{d divides n} (-1)^((1+d)*(1+n/d))*g(d) iff g(n) = Sum_{d divides n} (-1)^((1+d)*(1+n/d))*Mu(n/d)*f(d).
Each of the following two equations implies the other: F(x) = Sum_{n >= 1} (-1)^(n+1)*G(n*x); G(x) = Sum_{n >= 1} a(n)*F(n*x). See G. Pólya and G. Szegő, Part V111, Chap. 1, Nos. 66-68.2. (End)
Let D(n) denote the set of partitions of n into distinct parts. Then Sum_{parts k in D(n)} a(k) = |D(n-1)| = A000009(n-1). For example, D(6) = {6, 1 + 5, 2 + 4, 1 + 2 + 3} and the sum a(6) + (a(1) + a(5)) + (a(2) + a(4)) + (a(1) + a(2) + a(3)) = 3 = |D(5)|. - Peter Bala, Mar 14 2019
From Petros Hadjicostas, Jul 25 2020: (Start)
For p prime >= 2, Petrogradsky (2003) defined the multiplicative functions 1_p and mu_p in the following way:
1_p(n) = 1 when gcd(n,p) = 1 and 1_p(n) = 1 - p when gcd(n,p) = p;
mu_p(n) = mu(n) when gcd(n,p) = 1 and mu_p(n) = mu(m)*(p^s - p^(s-1)) when n = m*p^s with gcd(m,p) = 1 and s >= 1.
We have 1_2(n) = A062157(n), 1_3(n) = A061347(n) (with offset 1), a(n) = mu_2(n), and A117997(n) = mu_3(n) for n >= 1.
Some of the results by other contributors can be generalized:
(i) Rogel's (1897) formula becomes Sum_{d | n} 1_p(d) * mu_p(n/d) = 0 for n > 1. Thus, 1_p is the Dirichlet inverse of mu_p.
(ii) R. J. Mathar's Dirichlet g.f. for mu_p becomes 1/(zeta(s) * (1 - p^(1-s))). The Dirichlet g.f. for 1_p is zeta(s) * (1 - p^(1-s)).
(iii) Benoit Cloitre's formula becomes 1 = Sum_{k=1..n} mu_p(k)*g_p(n/k), where g_p(x) = floor(x) - p*floor(x/p) = floor(x) mod p.
(iv) Paul D. Hanna's formula becomes Sum_{n >= 1} (mu_p(n)/n)*log((1 - x^(n*p))/(1 - x^n)) = x.
(v) The definition of A117997 generalizes to Sum_{d | n} mu_p(d) = n, if n = p^s for s >= 0, and = 0, otherwise.
(vi) By differentiating both sides of (iv) w.r.t. x and multiplying both sides by x, we get Sum_{n >= 1} mu_p(n)*(x^n + 2*x^(2*n) + ... + (p-1)*x^(n*(p-1)))/(1 + x^n + x^(2*n) + ... + x^(n*(p-1))) = x, which generalizes one of Peter Bala's formulas. It can be thought as a "generalized Lambert series".
(vii) Obviously, f(n) = Sum_{d | n} 1_p(n/d)*g(d) if and only if g(n) = Sum_{d | n} mu_p(n/d)*f(d). (End)

References

  • G. Pólya and G. Szegő, Problems and Theorems in Analysis Volume II. Springer_Verlag 1976.

Crossrefs

Cf. A000009, A038712, A038838, A048298 (inverse Mobius transform), A061347, A062157, A085906, A117997, A321088 (Euler transform), A321558.

Programs

  • Mathematica
    a[n_] := If[n == 1, 1, Product[{p, e} = pe; If[2 == p, e--, If[e > 1, p = 0, p = -1]]; p^e, {pe, FactorInteger[n]}]];
    a /@ Range[1, 100] (* Jean-François Alcover, Oct 01 2019 *)
  • PARI
    {a(n)=local(k); if(n<1, 0, k=valuation(n, 2); moebius(n/2^k)*2^max(0, k-1))} /* Michael Somos, Aug 22 2006 */
    
  • PARI
    A067856(n) =  { my(f=factor(n)); for(i=1,#f~,if(2==f[i,1],f[i,2]--,if(f[i,2]>1,f[i,1]=0,f[i,1]=-1))); factorback(f); }; \\ Antti Karttunen, Sep 27 2018, after Vladeta Jovovic_'s multiplicative formula.

Formula

a(1) = 1 and a(n) = Sum{k | n, 1 < k} (-1)^k a(n/k) for n >= 2; the sum is over the divisors, k, of n, where k > 1. If n is odd, a(n) = mu(n), where mu(.) is the Moebius function. If n is even, a(n) = mu(m)* 2^(k-1), where n = m*2^k, m is odd integer, and k is a positive integer.
Sum_{n > 0} a(n)*x^n/(1 + x^n) = x. Moebius transform of A048298. Multiplicative with a(2^e) = 2^(e - 1), a(p) = -1 for p > 2, a(p^e) = 0 for p > 2 and e > 1. - Vladeta Jovovic, Jan 02 2003
Sum_{n > 0} a(n)*log(1 + x^n)/n = x. - Paul D. Hanna, May 06 2003
a(n) = 0 if and only if n is divisible by the square of an odd prime (A038838). - Michael Somos, Aug 22 2006
1 = Sum_{k=1..n} a(k)*g(n/k), where g(x) = floor(x) - 2*floor(x/2). - Benoit Cloitre, Nov 11 2010
Dirichlet g.f.: 1/( zeta(s) * (1 - 2^(1-s)) ). - R. J. Mathar, Apr 02 2011
From Peter Bala, Mar 13 2019: (Start)
Sum_{n >= 1} a(n)*x^n/(1 + x^n) = x
Sum_{n >= 1} a(n)*x^n/(1 - x^n) = x + 2*x^2 + 4*x^4 + 8*x^8 + 16*x^16 + ...
Sum_{n >= 1} a(n)*x^n/(1 + (-x)^n) = x + 2*(x^2 + x^4 + x^8 + x^16 + ...)
Sum_{n >= 1} a(n)*x^n/(1 - (-x)^n) = x + 2*(x^4 + 3*x^8 + 7*x^16 + 15*x^32 + ...). (End)
G.f. A(x) satisfies: A(x) = x + A(x^2) - A(x^3) + A(x^4) - A(x^5) + ... - Ilya Gutkovskiy, May 11 2019
Sum_{k=1..n} abs(a(k)) ~ 2*n*(log(n) - 1 + gamma + 11*log(2)/6 - 12*zeta'(2)/Pi^2) / (log(2)*Pi^2), where gamma is the Euler-Mascheroni constant A001620. - Vaclav Kotesovec, May 30 2024

A091512 a(n) is the largest integer m such that 2^m divides (2*n)^n, i.e., the exponent of 2 in (2*n)^n.

Original entry on oeis.org

1, 4, 3, 12, 5, 12, 7, 32, 9, 20, 11, 36, 13, 28, 15, 80, 17, 36, 19, 60, 21, 44, 23, 96, 25, 52, 27, 84, 29, 60, 31, 192, 33, 68, 35, 108, 37, 76, 39, 160, 41, 84, 43, 132, 45, 92, 47, 240, 49, 100, 51, 156, 53, 108, 55, 224, 57, 116, 59, 180, 61, 124, 63
Offset: 1

Views

Author

Ralf Stephan and Labos Elemer, Jan 18 2004

Keywords

Comments

n times one more than the trailing 0's in the binary representation of n. - Ralf Stephan, Aug 22 2013

Crossrefs

Programs

  • Magma
    [n*(Valuation(n, 2)+1): n in [1..80]]; // Vincenzo Librandi, May 16 2013
    
  • Maple
    nmax:=63: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := (2*n-1)*(p+1)*2^p od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Feb 08 2013
    # second Maple program:
    a:= n-> n*padic[ordp](2*n, 2):
    seq(a(n), n=1..63);  # Alois P. Heinz, Jan 02 2024
  • Mathematica
    Table[ Part[ Flatten[ FactorInteger[(2 n)^n]], 2], {n, 1, 124}]
    Table[IntegerExponent[(2n)^n,2],{n,70}] (* Harvey P. Dale, Sep 11 2015 *)
  • PARI
    a(n)=n*(valuation(n,2)+1)
    
  • PARI
    a(n)=if(n<1,0,if(n%2==0,2*a(n/2)+n,n))
    
  • Python
    def A091512(n): return n*(n&-n).bit_length() # Chai Wah Wu, Jul 11 2022

Formula

a(n) = A007814(A000312(n)) = n*A001511(n) = A069895(n)/2.
G.f.: Sum_{k>=0} 2^k*x^2^k/(1-x^2^k)^2.
Recurrence: a(0) = 0, a(2*n) = 2*a(n) + 2*n, a(2*n+1) = 2*n+1.
Dirichlet g.f.: zeta(s-1)*2^s/(2^s-2). - Ralf Stephan, Jun 17 2007
Mobius transform of A162728, where x/(1-x)^2 = Sum_{n>=1} A162728(n)*x^n/(1+x^n). - Paul D. Hanna, Jul 12 2009
a(n) = A162728(2*n)/phi(2*n), where x/(1-x)^2 = Sum_{n>=1} A162728(n)*x^n/(1+x^n). - Paul D. Hanna, Jul 12 2009
a((2*n-1)*2^p) = (2*n-1)*(p+1)*2^p, p >= 0. Observe that a(2^p) = A001787(p+1). - Johannes W. Meijer, Feb 08 2013
Sum_{k=1..n} a(k) ~ n^2. - Amiram Eldar, Oct 22 2022
a(n) = Sum_{d divides n} d*A048298(n/d); that is, a(n) is the Dirichlet product of A048298(n) and A000027(n). - Peter Bala, Jan 02 2024

A367168 The largest unitary divisor of n that is a term of A138302.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 3, 25, 26, 1, 28, 29, 30, 31, 1, 33, 34, 35, 36, 37, 38, 39, 5, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 2, 55, 7, 57, 58, 59, 60, 61, 62, 63, 1, 65, 66, 67, 68, 69, 70
Offset: 1

Views

Author

Amiram Eldar, Nov 07 2023

Keywords

Comments

First differs from A056192 at n = 32 and from A270418 at n = 128.

Crossrefs

Programs

  • Mathematica
    f[p_, e_] := If[e == 2^IntegerExponent[e, 2], p^e, 1]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100]
  • PARI
    a(n) = {my(f = factor(n)); prod(i = 1, #f~, if(f[i, 2] == 1 << valuation(f[i, 2], 2), f[i, 1]^f[i, 2], 1));}
    
  • Python
    from math import prod
    from sympy import factorint
    def A367168(n): return prod(p**e for p,e in factorint(n).items() if not(e&-e)^e) # Chai Wah Wu, Nov 10 2023

Formula

Multiplicative with a(p^e) = p^A048298(e).
a(n) <= n, with equality if and only if n is in A138302.
Sum_{k=1..n} a(k) ~ c * n^2 / 2, where c = 0.881513... (A065465).

A082495 a(n) = (2^n - 1) mod n.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 1, 7, 7, 3, 1, 3, 1, 3, 7, 15, 1, 9, 1, 15, 7, 3, 1, 15, 6, 3, 25, 15, 1, 3, 1, 31, 7, 3, 17, 27, 1, 3, 7, 15, 1, 21, 1, 15, 16, 3, 1, 15, 29, 23, 7, 15, 1, 27, 42, 31, 7, 3, 1, 15, 1, 3, 7, 63, 31, 63, 1, 15, 7, 43, 1, 63, 1, 3, 67, 15, 17, 63, 1, 15, 79, 3, 1, 63, 31, 3, 7, 79
Offset: 1

Views

Author

Anonymous, Apr 28 2003

Keywords

Crossrefs

Programs

Formula

a(n) = A015910(n) + A048298(n) - 1.

A059861 a(n) = Product_{i=2..n} (prime(i) - 2).

Original entry on oeis.org

1, 1, 3, 15, 135, 1485, 22275, 378675, 7952175, 214708725, 6226553025, 217929355875, 8499244879125, 348469040044125, 15681106801985625, 799736446901266875, 45584977473372211875, 2689513670928960500625
Offset: 1

Views

Author

Labos Elemer, Feb 28 2001

Keywords

Comments

Arises in Hardy-Littlewood k-tuple conjecture. Also a(n) is the exact number of d=2 and also d=4 differences in dRRS[modulus=n-th primorial]; see A049296 (dRRS[m]=set of first differences of reduced residue system modulo m).
For n>1 this is the determinant of the (n-1) X (n-1) matrix whose diagonal is A006093(n) = {1, 2, 4, 6, 10, 12, 16, 18..} = the first primes minus 1 and all other elements are 1's. The determinant begins: / (2-1) 1 1 1 1 1 1 ... / 1 (3-1) 1 1 1 1 1 ... / 1 1 (5-1) 1 1 1 1 ... / 1 1 1 (7-1) 1 1 1 ... / 1 1 1 1 (11-1) 1 1 ... / 1 1 1 1 1 (13-1) 1 ... - Alexander Adamchuk, May 21 2006
From Gary W. Adamson, Apr 21 2009: (Start)
Equals (-1)^n * (1, 1, 1, 3, 15, ...) dot (1, -2, 4, -6, 10, ...).
a(6) = 135 = (1, 1, 1, 3, 15) dot (1, -2, 4, -6, 10) = (1, -2, 4, -18, 150). (End)

Examples

			n=4, a(4) = 1*(3-2)*(5-2)*(7-2) = 15. 48 first terms of A049296 give one complete period of dRRS[210], in which 15 d=2, 15 d=4 and 18 larger differences occur. For n=1, 2, ..., 5 in the periods of length {1, 2, 8, 48, 480, ...} [see A005867] the number of d=2 and also d=4 differences is {1, 1, 3, 15, 135, ..}
		

References

  • Steven R. Finch, Mathematical Constants, Cambridge, 2003, pp. 84-94.
  • R. K. Guy, Unsolved Problems in Number Theory, Sections A8, A1.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford Univ. Press, 1979.
  • G. Polya, Mathematics and Plausible Reasoning, Vol. II, Appendix Princeton UP, 1954.

Crossrefs

Programs

  • Mathematica
    Table[ Det[ DiagonalMatrix[ Table[ Prime[i-1] - 2, {i, 2, n} ] ] + 1 ], {n, 2, 20} ] (* Alexander Adamchuk, May 21 2006 *)
    Table[Product[Prime@k - 2, {k, 2, n}], {n, 1, 18}] (* Harlan J. Brothers, Jul 02 2018 *)
    a[1] = 1; a[n_] := a[n] = a[n - 1] (Prime[n] - 2);
    Table[a[n], {n, 18}]  (* Harlan J. Brothers, Jul 02 2018 *)
    Join[{1},FoldList[Times,Prime[Range[2,20]]-2]] (* Harvey P. Dale, Apr 19 2023 *)
  • PARI
    a(n) = prod(i=2, n, prime(i)-2); \\ Michel Marcus, Apr 16 2017

Formula

a(n) = Det[ DiagonalMatrix[ Table[ Prime[i-1] - 2, {i, 2, n} ] ] + 1 ] for n>1. - Alexander Adamchuk, May 21 2006
a(n) = a(n-1) * (A000040(n) - 2) for n > 1. - A.H.M. Smeets, Dec 14 2019
a(n) = |{r | 0 <= r < primorial(n) and gcd(r, primorial(n)) = 1 and gcd(r + 2, primorial(n)) = 1}|. - Greg Tener, Oct 22 2021

Extensions

Offset corrected by A.H.M. Smeets, Dec 14 2019

A340675 Exponential of Mangoldt function conjugated by Tek's flip: a(n) = A225546(A014963(A225546(n))).

Original entry on oeis.org

1, 2, 2, 4, 2, 2, 2, 1, 4, 2, 2, 1, 2, 2, 2, 16, 2, 1, 2, 1, 2, 2, 2, 1, 4, 2, 1, 1, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 16, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 1, 4, 2, 2, 2, 1, 2
Offset: 1

Views

Author

Antti Karttunen and Peter Munn, Feb 01 2021

Keywords

Comments

Nonunit squarefree numbers take the value 2, other nonsquares take the value 1, and squares take the square of the value taken by their square root.

Crossrefs

Sequences used in a definition of this sequence: A014963, A048298, A225546, A267116, A297108, A340676.
Positions of 1's: {1} U A340681, 2's: A005117 \ {1}, of 4's: A062503 \ {1}, of 16's: A113849.
Positions of terms > 1: A340682, of terms > 2: A340674.
Sequences used to express relationship between terms of this sequence: A003961, A331590.

Programs

  • PARI
    A340675(n) = if(1==n,n,if(issquarefree(n), 2, if(!issquare(n), 1, A340675(sqrtint(n))^2)));

Formula

a(n) = 2^A048298(A267116(n)).
If A340673(n) = 1, then a(n) = 1, otherwise a(n) = 2^A297108(A340673(n)).
If A340676(n) = 0, then a(n) = 1, otherwise a(n) = 2^(2^(A340676(n)-1)).
If n = s^(2^k), s squarefree >= 2, k >= 0, then a(n) = 2^(2^k), otherwise a(n) = 1.
For n, k > 1, if a(n) = a(k) then a(A331590(n, k)) = a(n), otherwise a(A331590(n, k)) = 1.
a(n^2) = a(n)^2.
a(A003961(n)) = a(n).
a(A051144(n)) = 1.
a(n) = 1 if and only if A331591(n) <> 1, otherwise a(n) = 2^A051903(n).
Showing 1-10 of 25 results. Next