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 12 results. Next

A018805 Number of elements in the set {(x,y): 1 <= x,y <= n, gcd(x,y)=1}.

Original entry on oeis.org

1, 3, 7, 11, 19, 23, 35, 43, 55, 63, 83, 91, 115, 127, 143, 159, 191, 203, 239, 255, 279, 299, 343, 359, 399, 423, 459, 483, 539, 555, 615, 647, 687, 719, 767, 791, 863, 899, 947, 979, 1059, 1083, 1167, 1207, 1255, 1299, 1391, 1423, 1507, 1547, 1611, 1659, 1763
Offset: 1

Views

Author

Keywords

Comments

Number of positive rational numbers of height at most n, where the height of p/q is max(p, q) when p and q are relatively prime positive integers. - Charles R Greathouse IV, Jul 05 2012
The number of ordered pairs (i,j) with 1<=i<=n, 1<=j<=n, gcd(i,j)=d is a(floor(n/d)). - N. J. A. Sloane, Jul 29 2012
Equals partial sums of A140434 (1, 2, 4, 4, 8, 4, 12, 8, ...) and row sums of triangle A143469. - Gary W. Adamson, Aug 17 2008
Number of distinct solutions to k*x+h=0, where 1 <= k,h <= n. - Giovanni Resta, Jan 08 2013
a(n) is the number of rational numbers which can be constructed from the set of integers between 1 and n, without combination of multiplication and division. a(3) = 7 because {1, 2, 3} can only create {1/3, 1/2, 2/3, 1, 3/2, 2, 3}. - Bernard Schott, Jul 07 2019

References

  • S. R. Finch, Mathematical Constants, Cambridge, 2003, pp. 110-112.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954. See Theorem 332.

Crossrefs

Cf. A177853 (partial sums).
The main diagonal of A331781, also of A333295.

Programs

  • Haskell
    a018805 n = length [()| x <- [1..n], y <- [1..n], gcd x y == 1]
    -- Reinhard Zumkeller, Jan 21 2013
    
  • Magma
    /* based on the first formula */ A018805:=func< n | 2*&+[ EulerPhi(k): k in [1..n] ]-1 >; [ A018805(n): n in [1..60] ]; // Klaus Brockhaus, Jan 27 2011
    
  • Magma
    /* based on the second formula */ A018805:=func< n | n eq 1 select 1 else n^2-&+[ $$(n div j): j in [2..n] ] >; [ A018805(n): n in [1..60] ]; // Klaus Brockhaus, Feb 07 2011
    
  • Maple
    N:= 1000; # to get the first N entries
    P:= Array(1..N,numtheory:-phi);
    A:= map(t -> 2*round(t)-1, Statistics:-CumulativeSum(P));
    convert(A,list); # Robert Israel, Jul 16 2014
  • Mathematica
    FoldList[ Plus, 1, 2 Array[ EulerPhi, 60, 2 ] ] (* Olivier Gérard, Aug 15 1997 *)
    Accumulate[2*EulerPhi[Range[60]]]-1 (* Harvey P. Dale, Oct 21 2013 *)
  • PARI
    a(n)=sum(k=1,n,moebius(k)*(n\k)^2)
    
  • PARI
    A018805(n)=2 *sum(j=1, n, eulerphi(j)) - 1;
    for(n=1, 99, print1(A018805(n), ", ")); /* show terms */
    
  • PARI
    a(n)=my(s); forsquarefree(k=1,n, s+=moebius(k)*(n\k[1])^2); s \\ Charles R Greathouse IV, Jan 08 2018
    
  • Python
    from sympy import sieve
    def A018805(n): return 2*sum(t for t in sieve.totientrange(1,n+1)) - 1 # Chai Wah Wu, Mar 23 2021
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def A018805(n): # based on second formula
        if n == 0:
            return 0
        c, j = 1, 2
        k1 = n//j
        while k1 > 1:
            j2 = n//k1 + 1
            c += (j2-j)*A018805(k1)
            j, k1 = j2, n//j2
        return n*(n-1)-c+j # Chai Wah Wu, Mar 24 2021

Formula

a(n) = 2*(Sum_{j=1..n} phi(j)) - 1.
a(n) = n^2 - Sum_{j=2..n} a(floor(n/j)).
a(n) = 2*A015614(n) + 1. - Reinhard Zumkeller, Apr 08 2006
a(n) = 2*A002088(n) - 1. - Hugo van der Sanden, Nov 22 2008
a(n) ~ (1/zeta(2)) * n^2 = (6/Pi^2) * n^2 as n goes to infinity (zeta is the Riemann zeta function, A013661, and the constant 6/Pi^2 is 0.607927..., A059956). - Ahmed Fares (ahmedfares(AT)my-deja.com), Jul 18 2001
a(n) ~ 6*n^2/Pi^2 + O(n*log n). - N. J. A. Sloane, May 31 2020
a(n) = Sum_{k=1..n} mu(k)*floor(n/k)^2. - Benoit Cloitre, May 11 2003
a(n) = A000290(n) - A100613(n) = A015614(n) + A002088(n). - Reinhard Zumkeller, Jan 21 2013
a(n) = A242114(floor(n/k),1), 1<=k<=n; particularly a(n) = A242114(n,1). - Reinhard Zumkeller, May 04 2014
a(n) = 2 * A005728(n) - 3. - David H Post, Dec 20 2016
a(n) ~ 6*n^2/Pi^2, cf. A059956. [Hardy and Wright] - M. F. Hasler, Jan 20 2017
G.f.: (1/(1 - x)) * (-x + 2 * Sum_{k>=1} mu(k) * x^k / (1 - x^k)^2). - Ilya Gutkovskiy, Feb 14 2020

Extensions

More terms from Reinhard Zumkeller, Apr 08 2006
Link to Moree's paper corrected by Peter Luschny, Aug 08 2009

A319998 a(n) = Sum_{d|n, d is even} mu(n/d)*d, where mu(n) is Moebius function A008683.

Original entry on oeis.org

0, 2, 0, 2, 0, 4, 0, 4, 0, 8, 0, 4, 0, 12, 0, 8, 0, 12, 0, 8, 0, 20, 0, 8, 0, 24, 0, 12, 0, 16, 0, 16, 0, 32, 0, 12, 0, 36, 0, 16, 0, 24, 0, 20, 0, 44, 0, 16, 0, 40, 0, 24, 0, 36, 0, 24, 0, 56, 0, 16, 0, 60, 0, 32, 0, 40, 0, 32, 0, 48, 0, 24, 0, 72, 0, 36, 0, 48, 0, 32, 0, 80, 0, 24, 0, 84, 0, 40, 0, 48, 0, 44, 0, 92, 0, 32, 0, 84, 0, 40, 0, 64, 0, 48, 0
Offset: 1

Views

Author

Antti Karttunen, Oct 31 2018

Keywords

Crossrefs

Programs

  • Mathematica
    Rest[CoefficientList[Series[Sum[2*MoebiusMu[k]*x^(2*k)/(1 - x^(2*k))^2, {k, 1, 100}], {x, 0, 100}], x]] (* Vaclav Kotesovec, Nov 03 2018 *)
  • PARI
    A319998(n) = sumdiv(n,d,(!(d%2))*moebius(n/d)*d);
    
  • PARI
    A319998(n) = if(n%2, 0, 2*eulerphi(n/2));

Formula

a(n) = Sum_{d|n} A059841(d)*A008683(n/d)*d.
a(n) = A000010(n) - A319997(n).
a(2n) = 2*A000010(n), a(2n+1) = 0.
G.f.: Sum_{k>=1} 2*mu(k)*x^(2*k)/(1 - x^(2*k))^2. - Ilya Gutkovskiy, Nov 02 2018
Sum_{k=1..n} a(k) ~ c * n^2, where c = 3/(2*Pi^2) = 0.151981... . - Amiram Eldar, Nov 12 2022

A353747 a(n) = phi(n) + A064989(n), where phi is Euler totient function, and A064989 shifts the prime factorization one step towards lower primes.

Original entry on oeis.org

2, 2, 4, 3, 7, 4, 11, 5, 10, 7, 17, 6, 23, 11, 14, 9, 29, 10, 35, 11, 22, 17, 41, 10, 29, 23, 26, 17, 51, 14, 59, 17, 34, 29, 39, 16, 67, 35, 46, 19, 77, 22, 83, 27, 36, 41, 89, 18, 67, 29, 58, 35, 99, 26, 61, 29, 70, 51, 111, 22, 119, 59, 56, 33, 81, 34, 127, 45, 82, 39, 137, 28, 143, 67, 58, 53, 95, 46, 151, 35, 70
Offset: 1

Views

Author

Antti Karttunen, May 06 2022

Keywords

Crossrefs

Programs

  • Mathematica
    f1[p_, e_] := (p - 1)*p^(e - 1); f2[p_, e_] := If[p == 2, 1, NextPrime[p, -1]^e]; a[1] = 2; a[n_] := Times @@ f1 @@@ (f = FactorInteger[n]) + Times @@ f2 @@@ f; Array[a, 80] (* Amiram Eldar, May 07 2022 *)
  • PARI
    A064989(n) = { my(f=factor(n>>valuation(n,2))); for(i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f); };
    A353747(n) = (eulerphi(n)+A064989(n));

Formula

a(n) = A000010(n) + A064989(n).
For n >= 0, a(4n+2) = a(2n+1).
For n > 1, a(n) = A140434(n) - A353748(n).
Sum_{k=1..n} a(k) ~ c * n^2, where c = (1/2) * Product_{p prime} ((p^2-p)/(p^2-q(p))) + 3/Pi^2 = 0.524667479..., where q(p) = prevprime(p) (A151799) if p > 2 and q(2) = 1. - Amiram Eldar, Dec 21 2023

A353748 a(n) = phi(n) - A064989(n), where phi is Euler totient function, and A064989 shifts the prime factorization one step towards lower primes.

Original entry on oeis.org

0, 0, 0, 1, 1, 0, 1, 3, 2, 1, 3, 2, 1, 1, 2, 7, 3, 2, 1, 5, 2, 3, 3, 6, 11, 1, 10, 7, 5, 2, 1, 15, 6, 3, 9, 8, 5, 1, 2, 13, 3, 2, 1, 13, 12, 3, 3, 14, 17, 11, 6, 13, 5, 10, 19, 19, 2, 5, 5, 10, 1, 1, 16, 31, 15, 6, 5, 19, 6, 9, 3, 20, 1, 5, 22, 19, 25, 2, 5, 29, 38, 3, 3, 14, 25, 1, 10, 33, 5, 12, 17, 25, 2, 3, 21
Offset: 1

Views

Author

Antti Karttunen, May 06 2022

Keywords

Crossrefs

Programs

  • Mathematica
    f1[p_, e_] := (p - 1)*p^(e - 1); f2[p_, e_] := If[p == 2, 1, NextPrime[p, -1]^e]; a[1] = 0; a[n_] := Times @@ f1 @@@ (f = FactorInteger[n]) - Times @@ f2 @@@ f; Array[a, 100] (* Amiram Eldar, May 07 2022 *)
  • PARI
    A064989(n) = { my(f=factor(n>>valuation(n,2))); for(i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f); };
    A353748(n) = (eulerphi(n)-A064989(n));

Formula

a(n) = A000010(n) - A064989(n).
For n >= 0, a(4n+2) = a(2n+1).
For n > 1, a(n) = A140434(n) - A353747(n).
Sum_{k=1..n} a(k) ~ c * n^2, where c = 3/Pi^2 - (1/2) * Product_{p prime} ((p^2-p)/(p^2-q(p))) = 0.0832596219... , where q(p) = prevprime(p) (A151799) if p > 2 and q(2) = 1. - Amiram Eldar, Dec 21 2023

A344597 a(n) = Sum_{k=1..n} mu(k) * (floor(n/k)^4 - floor((n-1)/k)^4).

Original entry on oeis.org

1, 14, 64, 160, 368, 592, 1104, 1520, 2400, 3056, 4640, 5264, 7824, 8736, 11776, 13216, 17984, 18384, 25344, 26080, 33312, 35120, 45584, 44320, 58480, 58512, 72000, 73200, 92624, 86848, 113520, 110144, 132640, 132416, 162816, 152112, 194544, 185616, 220416
Offset: 1

Views

Author

Seiichi Manyama, May 24 2021

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := Sum[MoebiusMu[k] * First @ Differences @ (Quotient[{n - 1, n}, k]^4), {k, 1, n}]; Array[a, 50] (* Amiram Eldar, May 24 2021 *)
  • PARI
    a(n) = sum(k=1, n, moebius(k)*((n\k)^4-((n-1)\k)^4));
    
  • PARI
    my(N=40, x='x+O('x^N)); Vec(sum(k=1, N, moebius(k)*x^k*(1+11*x^k+11*x^(2*k)+x^(3*k))/(1-x^k)^4))
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def A082540(n):
        if n == 0:
            return 0
        c, j = 1, 2
        k1 = n//j
        while k1 > 1:
            j2 = n//k1 + 1
            c += (j2-j)*A082540(k1)
            j, k1 = j2, n//j2
        return n*(n**3-1)-c+j
    def A344597(n): return A082540(n)-A082540(n-1) # Chai Wah Wu, May 09 2025

Formula

Sum_{k=1..n} a(k) * floor(n/k) = n^4.
Sum_{k=1..n} a(k) = A082540(n).
G.f.: Sum_{k >= 1} mu(k) * x^k * (1 + 11*x^k + 11*x^(2*k) + x^(3*k))/(1 - x^k)^4.

A086227 a(n) = Sum_{1<=k<=4*n, gcd(k,n)=1} (i^k*tan(k*Pi/(4*n)))/(4*i), where i is the imaginary unit.

Original entry on oeis.org

-1, 2, -2, 2, -4, 4, -4, 6, -4, 6, -8, 6, -8, 8, -8, 8, -12, 10, -8, 16, -12, 12, -16, 10, -12, 18, -16, 14, -16, 16, -16, 24, -16, 16, -24, 18, -20, 24, -16, 20, -32, 22, -24, 24, -24, 24, -32, 28, -20, 32, -24, 26, -36, 24, -32, 40, -28, 30, -32, 30, -32, 48, -32, 24, -48, 34, -32, 48, -32, 36, -48, 36, -36, 40, -40, 48, -48
Offset: 2

Views

Author

Benoit Cloitre, Aug 28 2003

Keywords

Comments

This seems to be (-1)^(n+1) times h(-4n^2) = (-1)^(n+1)*A000003(n^2), where h(k) is the class number. Verified for n <= 10^5. - Charles R Greathouse IV, Apr 28 2013

Crossrefs

Programs

  • Mathematica
    f[p_, e_] := p^(e - 1) * Switch[Mod[p, 4], 2, 1, 1, p - 1, 3, p + 1]; s[n_] := Times @@ f @@@ FactorInteger[n]; a[n_] := If[EvenQ[n], -s[n], s[n]/2]; Array[a, 100, 2] (* Amiram Eldar, Mar 07 2022 *)
  • PARI
    a(n)=round(real(1/4/I*sum(k=1,4*n,(I^k)*tan(Pi/4/n*if(gcd(k,n)-1,0,k)))))
    
  • PARI
    a(n)=round(imag(sum(k=1,4*n,if(gcd(k,n)==1,I^k*tan(k*Pi/4/n))))/4) \\ Charles R Greathouse IV, Apr 25 2013
    
  • PARI
    a(n)=my(s);for(k=1,2*n,if(gcd(2*k-1,n)==1,s-=(-1)^k*tan((2*k-1)*Pi/4/n))); round(s/4) \\ Charles R Greathouse IV, Apr 25 2013

Formula

a(n) = -A204617(n) if n is even, and A204617(n)/2 if n is odd (Rabinowitz, 1996). - Amiram Eldar, Mar 07 2022
a(n) = (-1)^(n+1)*A079458(n)/A140434(n). - Ridouane Oudra, Jun 23 2024

Extensions

Definition corrected by Charles R Greathouse IV, Apr 25 2013

A143467 Triangle read by rows, A143315 * A128407, 1<=k<=n.

Original entry on oeis.org

1, 3, -1, 5, 0, -1, 7, -3, 0, 0, 9, 0, 0, 0, -1, 11, -5, -3, 0, 0, 1, 13, 0, 0, 0, 0, 0, -1, 15, -7, 0, 0, 0, 0, 0, 0, 17, 0, -5, 0, 0, 0, 0, 0, 0, 19, -9, 0, 0, -3, 0, 0, 0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 23, -11, -7, 0, 0, 3, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1
Offset: 1

Views

Author

Gary W. Adamson, Aug 17 2008

Keywords

Comments

Row sums = A140434: (1, 2, 4, 4, 8, 4, 12, 8, 12,...).
Right border = mu(n), A008683: (1, -1, -1, 0, -1, 1,...).

Examples

			First few rows of the triangle =
1;
3, -1;
5, 0, -1;
7, -3, 0, 0;
9, 0, 0, 0, -1;
11, -5, -3, 0, 0, 1;
13, 0, 0, 0, 0, 0, -1;
...
		

Crossrefs

Extensions

a(66) corrected by Georg Fischer, Aug 14 2023

A344596 a(n) = Sum_{k=1..n} mu(k) * (floor(n/k)^3 - floor((n-1)/k)^3).

Original entry on oeis.org

1, 6, 18, 30, 60, 66, 126, 132, 198, 204, 330, 276, 468, 414, 552, 552, 816, 630, 1026, 840, 1116, 1050, 1518, 1128, 1740, 1476, 1890, 1692, 2436, 1704, 2790, 2256, 2820, 2544, 3384, 2556, 3996, 3186, 3960, 3408, 4920, 3420, 5418, 4260, 5112, 4686, 6486, 4560, 6930, 5340, 6816
Offset: 1

Views

Author

Seiichi Manyama, May 24 2021

Keywords

Crossrefs

Essentially 6*A102309 and 6*A326419.

Programs

  • Mathematica
    a[n_] := Sum[MoebiusMu[k] * First @ Differences @ (Quotient[{n - 1, n}, k]^3), {k, 1, n}]; Array[a, 50] (* Amiram Eldar, May 24 2021 *)
  • PARI
    a(n) = sum(k=1, n, moebius(k)*((n\k)^3-((n-1)\k)^3));
    
  • PARI
    a(n) = if(n<2, n, 3*sumdiv(n, d, moebius(n/d)*(d-1)*d));
    
  • PARI
    my(N=66, x='x+O('x^N)); Vec(sum(k=1, N, moebius(k)*x^k*(1+4*x^k+x^(2*k))/(1-x^k)^3))
    
  • PARI
    my(N=66, x='x+O('x^N)); Vec(x+6*sum(k=1, N, moebius(k)*x^(2*k)/(1-x^k)^3))
    
  • Python
    from sympy import mobius, divisors
    def A344596(n): return 3*sum(mobius(n//d)*d*(d-1) for d in divisors(n,generator=True)) if n>1 else 1 # Chai Wah Wu, May 09 2025

Formula

Sum_{k=1..n} a(k) * floor(n/k) = n^3.
Sum_{k=1..n} a(k) = A071778(n).
a(n) = 3 * Sum_{d|n} mu(n/d) * (d-1) * d for n > 1.
G.f.: Sum_{k >= 1} mu(k) * x^k * (1 + 4*x^k + x^(2*k))/(1 - x^k)^3.
G.f.: x + 6 * Sum_{k>=1} mu(k) * x^(2*k)/(1 - x^k)^3.
a(2^k) = 3*2^(k-2)*(3*2^k-2) for k>0. - Chai Wah Wu, May 10 2025

A140435 Number of new lattice points created at each step in an n X n grid that are not visible.

Original entry on oeis.org

0, 1, 1, 3, 1, 7, 1, 7, 5, 11, 1, 15, 1, 15, 13, 15, 1, 23, 1, 23, 17, 23, 1, 31, 9, 27, 17, 31, 1, 43, 1, 31, 25, 35, 21, 47, 1, 39, 29, 47, 1, 59, 1, 47, 41, 47, 1, 63, 13, 59, 37, 55, 1, 71, 29, 63, 41, 59, 1, 87, 1, 63, 53, 63, 33, 91, 1, 71, 49, 91, 1, 95, 1, 75, 69, 79, 33, 107, 1, 95, 53
Offset: 1

Views

Author

Gregg Whisler, Jun 25 2008

Keywords

Crossrefs

Programs

  • Mathematica
    g[n_] := Table[ #^2 &[m], {m, 1, n + 1}] - FoldList[Plus, 1, 2 Array[EulerPhi, n, 2]] - Most[Flatten[ Append[{0}, Table[ #^2 &[m], {m, 1, n + 1}] - FoldList[Plus, 1, 2 Array[EulerPhi, n, 2]]]]]; g[80]

Formula

G.f.: -Sum_{k>=2} mu(k) * x^k * (1 + x^k) / (1 - x^k)^2. - Ilya Gutkovskiy, Sep 14 2021

Extensions

More terms from Robert G. Wilson v, Jan 17 2011

A143316 Triangle read by rows, A054525 * A143315, 1<=k<=n.

Original entry on oeis.org

1, 2, 1, 4, 0, 1, 4, 2, 0, 1, 8, 0, 0, 0, 1, 4, 4, 2, 0, 0, 1, 12, 0, 0, 0, 0, 0, 1, 8, 4, 0, 2, 0, 0, 0, 1, 12, 0, 4, 0, 0, 0, 0, 0, 1, 8, 8, 0, 0, 2, 0, 0, 0, 0, 1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 4, 4, 4, 0, 2, 0, 0, 0, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 12, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1
Offset: 1

Views

Author

Gary W. Adamson, Aug 06 2008

Keywords

Comments

Row sums = 2*n-1.
Left border = A140434: (1, 2, 4, 4, 8, 4, 12, 8,...).

Examples

			First few rows of the triangle =
1;
2, 1;
4, 0, 1;
4, 2, 0, 1;
8, 0, 0, 0, 1;
4, 4, 2, 0, 0, 1;
12, 0, 0, 0, 0, 0, 1;
8, 4, 0, 2, 0, 0, 0, 1;
...
		

Crossrefs

Extensions

a(19) corrected and more terms from Georg Fischer, Aug 14 2023
Showing 1-10 of 12 results. Next