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-7 of 7 results.

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

A358298 Array read by antidiagonals: T(n,k) (n>=0, k>=0) = number of lines defining the Farey diagram Farey(n,k) of order (n,k).

Original entry on oeis.org

2, 3, 3, 4, 6, 4, 6, 11, 11, 6, 8, 19, 20, 19, 8, 12, 29, 36, 36, 29, 12, 14, 43, 52, 60, 52, 43, 14, 20, 57, 78, 88, 88, 78, 57, 20, 24, 77, 100, 128, 124, 128, 100, 77, 24, 30, 97, 136, 162, 180, 180, 162, 136, 97, 30, 34, 121, 166, 216, 224, 252, 224, 216, 166, 121, 34
Offset: 0

Views

Author

Keywords

Comments

We work with lines with equation ux + vy + w = 0 in the (x,y) plane.
This line has slope -u/v, and crosses the vertical y axis at the intercept point y = -w/v
For the Farey diagram Farey(m,n), u is an integer between -(m-1) and +(m-1), v is between -(n-1) and +(n-1) and w can be any integer.
The only lines that are used are those that hit the unit square 0 <= x <= 1, 0 <= y <= 1 in at least two points.
This means that we only need to look at w's with |w| <= |u| + |v|.
T(m,n) is the number of such lines.
For illustrations of Farey(3,3) and Farey(3,4) see Khoshnoudirad (2015), Fig. 2, and Darat et al. (2009), Fig. 2. For further illustrations see A358882-A358885.

Examples

			The full array T(n,k), n >= 0, k>= 0, begins:
  2, 3, 4, 6, 8, 12, 14, 20, 24, 30, 34, 44, 48, 60,  ...
  3, 6, 11, 19, 29, 43, 57, 77, 97, 121, 145, 177, 205,  ...
  4, 11, 20, 36, 52, 78, 100, 136, 166, 210, 246, 302,  ...
  6, 19, 36, 60, 88, 128, 162, 216, 266, 326, 386, 468, ...
  8, 29, 52, 88, 124, 180, 224, 298, 360, 444, 518, 628, ...
  12, 43, 78, 128, 180, 252, 316, 412, 498, 608, 706,  ...
  14, 57, 100, 162, 224, 316, 388, 508, 608, 738, 852, ...
  ...
		

Crossrefs

Cf. A358299.
Row 0 is essentially A225531, row 1 is A358300, main diagonal is A358301.
The Farey Diagrams Farey(m,n) are studied in A358298-A358307 and A358882-A358885, the Completed Farey Diagrams of order (m,n) in A358886-A358889.

Programs

  • Maple
    A005728 := proc(n) 1+add(numtheory[phi](i), i=1..n) ; end proc: # called F_n in the paper
    Amn:=proc(m,n) local a,i,j;  # A331781 or equally A333295. Diagonal is A018805.
    a:=0; for i from 1 to m do for j from 1 to n do
    if igcd(i,j)=1 then a:=a+1; fi; od: od: a; end;
    # The present sequence is:
    Dmn:=proc(m,n) local d,t1,u,v,a; global A005728, Amn;
    a:=A005728(m)+A005728(n);
    t1:=0; for u from 1 to m do for v from 1 to n do
    d:=igcd(u,v); if d>=1 then t1:=t1 + (u+v)*numtheory[phi](d)/d; fi; od: od:
    a+2*t1-2*Amn(m,n); end;
    for m from 1 to 8 do lprint([seq(Dmn(m,n),n=1..20)]); od:
  • Mathematica
    A005728[n_] := 1 + Sum[EulerPhi[i], {i, 1, n}];
    Amn[m_, n_] := Module[{a, i, j}, a = 0; For[i = 1, i <= m, i++, For[j = 1, j <= n, j++, If[GCD[i, j] == 1, a = a + 1]]]; a];
    Dmn[m_, n_] := Module[{d, t1, u, v, a}, a = A005728[m] + A005728[n]; t1 = 0; For[u = 1, u <= m, u++, For[v = 1, v <= n, v++, d = GCD[u, v]; If[d >= 1 , t1 = t1 + (u + v)* EulerPhi[d]/d]]]; a + 2*t1 - 2*Amn[m, n]];
    Table[Dmn[m - n, n], {m, 0, 10}, {n, 0, m}] // Flatten (* Jean-François Alcover, Apr 03 2023, after Maple code *)

A331781 Triangle read by rows: T(m,n) = Sum_{0= n >= 1.

Original entry on oeis.org

0, 0, 1, 0, 2, 3, 0, 3, 5, 7, 0, 4, 6, 9, 11, 0, 5, 8, 12, 15, 19, 0, 6, 9, 13, 16, 21, 23, 0, 7, 11, 16, 20, 26, 29, 35, 0, 8, 12, 18, 22, 29, 32, 39, 43, 0, 9, 14, 20, 25, 33, 36, 44, 49, 55, 0, 10, 15, 22, 27, 35, 38, 47, 52, 59, 63, 0, 11, 17, 25, 31, 40, 44, 54, 60, 68, 73, 83
Offset: 1

Views

Author

N. J. A. Sloane, Feb 11 2020

Keywords

Examples

			Triangle begins:
0,
0, 1,
0, 2, 3,
0, 3, 5, 7,
0, 4, 6, 9, 11,
0, 5, 8, 12, 15, 19,
0, 6, 9, 13, 16, 21, 23,
0, 7, 11, 16, 20, 26, 29, 35,
0, 8, 12, 18, 22, 29, 32, 39, 43,
0, 9, 14, 20, 25, 33, 36, 44, 49, 55
...
		

Crossrefs

Main diagonal is A018805.
A333295 is essentially the same array.

Programs

  • Maple
    VS := proc(m,n) local a,i,j; a:=0;
    for i from 1 to m-1 do for j from 1 to n-1 do
    if gcd(i,j)=1 then a:=a+1; fi; od: od: a; end;
    for m from 1 to 12 do lprint([seq(VS(m,n),n=1..m)]); od:
  • Mathematica
    Table[Sum[Boole[# == 1] # &@ GCD[i, j], {i, m - 1}, {j, n - 1}], {m, 12}, {n, m}] // Flatten (* Michael De Vlieger, Feb 12 2020 *)

A358304 Array read by antidiagonals: T(n,k) (n>=0, k>=0) = number of decreasing lines defining the Farey diagram Farey(n,k) of order (n,k).

Original entry on oeis.org

0, 0, 0, 0, 2, 0, 0, 5, 5, 0, 0, 9, 10, 9, 0, 0, 14, 19, 19, 14, 0, 0, 20, 27, 32, 27, 20, 0, 0, 27, 40, 47, 47, 40, 27, 0, 0, 35, 51, 68, 66, 68, 51, 35, 0, 0, 44, 68, 85, 96, 96, 85, 68, 44, 0, 0, 54, 82, 112, 118, 134, 118, 112, 82, 54, 0, 0, 65, 103, 137, 156, 167, 167, 156, 137, 103, 65, 0, 0, 77, 120, 166, 187, 217, 204, 217, 187, 166, 120, 77, 0
Offset: 0

Views

Author

Keywords

Examples

			The full array T(n,k), n >= 0, k >= 0, begins:
  0,  0,  0,  0,   0,   0,   0,   0,   0,   0,   0,   0,   0, ..
  0,  2,  5,  9,  14,  20,  27,  35,  44,  54,  65,  77,  90, ..
  0,  5, 10, 19,  27,  40,  51,  68,  82, 103, 120, 145, 165, ..
  0,  9, 19, 32,  47,  68,  85, 112, 137, 166, 196, 235, 265, ..
  0, 14, 27, 47,  66,  96, 118, 156, 187, 229, 266, 320, 358, ..
  0, 20, 40, 68,  96, 134, 167, 217, 261, 317, 366, 436, 491, ..
  0, 27, 51, 85, 118, 167, 204, 267, 318, 384, 441, 528, 589, ..
  ...
		

Crossrefs

Cf. A358298.
The Farey Diagrams Farey(m,n) are studied in A358298-A358307 and A358882-A358885, the Completed Farey Diagrams of order (m,n) in A358886-A358889.

Programs

  • Maple
    A005728 := proc(n) 1+add(numtheory[phi](i), i=1..n) ; end proc: # called F_n in the paper
    Amn:=proc(m,n) local a,i,j;  # A331781 or equally A333295. Diagonal is A018805.
    a:=0; for i from 1 to m do for j from 1 to n do
    if igcd(i,j)=1 then a:=a+1; fi; od: od: a; end;
    DFD:=proc(m,n) local d,t1,u,v; global A005728, Amn;
    t1:=0; for u from 1 to m do for v from 1 to n do
    d:=igcd(u,v); if d>=1 then t1:=t1 + (u+v)*numtheory[phi](d)/d; fi; od: od:
    t1; end;
    for m from 0 to 8 do lprint([seq(DFD(m,n),n=0..20)]); od:
  • Mathematica
    T[n_, k_] := Sum[d = GCD[u, v]; If[d >= 1, (u+v)*EulerPhi[d]/d, 0], {u, 1, n}, {v, 1, k}];
    Table[T[n-k, k], {n, 0, 12}, {k, 0, n}] // Flatten (* Jean-François Alcover, Apr 18 2023 *)

A333297 a(n) = Sum_{i=1..n, j=1..n, gcd(i,j)=1} i.

Original entry on oeis.org

1, 4, 13, 25, 55, 73, 136, 184, 265, 325, 490, 562, 796, 922, 1102, 1294, 1702, 1864, 2377, 2617, 2995, 3325, 4084, 4372, 5122, 5590, 6319, 6823, 8041, 8401, 9796, 10564, 11554, 12370, 13630, 14278, 16276, 17302, 18706, 19666, 22126, 22882, 25591, 26911, 28531, 30049, 33292, 34444, 37531, 39031
Offset: 1

Views

Author

N. J. A. Sloane, Mar 25 2020

Keywords

Crossrefs

Programs

  • Maple
    Vi := proc(m,n) local a,i,j; a:=0;
    for i from 1 to m do for j from 1 to n do
    if igcd(i,j)=1 then a:=a+i; fi; od: od: a; end;
    # the diagonal :
    [seq(Vi(n,n),n=1..50)];
    # second Maple program:
    a:= proc(n) option remember; `if`(n<2, n,
          a(n-1) + 3*n*numtheory[phi](n)/2)
        end:
    seq(a(n), n=1..50);  # Alois P. Heinz, Mar 25 2020
  • Mathematica
    a[n_] := a[n] = If[n < 2, n, a[n - 1] + 3 n EulerPhi[n]/2];
    Array[a, 50] (* Jean-François Alcover, Nov 27 2020, after Alois P. Heinz *)
  • PARI
    a(n)={my(s=0);for(i=1,n,for(j=1,n,if(gcd(i,j)==1,s+=i)));s};
    for(k=1,45,print1(a(k),", ")) \\ Hugo Pfoertner, Mar 25 2020

Formula

From Alois P. Heinz, Mar 25 2020: (Start)
a(n) = a(n-1) + 3*n*phi(n)/2 for n > 1, a(n) = n for n <= 1.
a(n) = 1 + Sum_{k=2..n} 3*k*phi(k)/2. (End)
a(n) = a(n-1) + 3 * A023896(n) for n > 1. - Hugo Pfoertner, Mar 26 2020
a(n) ~ (3/Pi^2) * n^3. - Amiram Eldar, Dec 01 2024

A358299 Triangle read by antidiagonals: T(n,k) (n>=0, 0 <= k <= n) = number of lines defining the Farey diagram of order (n,k).

Original entry on oeis.org

2, 3, 6, 4, 11, 20, 6, 19, 36, 60, 8, 29, 52, 88, 124, 12, 43, 78, 128, 180, 252, 14, 57, 100, 162, 224, 316, 388, 20, 77, 136, 216, 298, 412, 508, 652, 24, 97, 166, 266, 360, 498, 608, 780, 924, 30, 121, 210, 326, 444, 608, 738, 940, 1116, 1332, 34, 145, 246, 386, 518, 706, 852, 1086, 1280, 1532, 1748
Offset: 0

Views

Author

Keywords

Examples

			The full array T(n,k), n >= 0, k>= 0, begins:
2, 3, 4, 6, 8, 12, 14, 20, 24, 30, 34, 44, 48, 60, ...
3, 6, 11, 19, 29, 43, 57, 77, 97, 121, 145, 177, 205, ...
4, 11, 20, 36, 52, 78, 100, 136, 166, 210, 246, 302, ...
6, 19, 36, 60, 88, 128, 162, 216, 266, 326, 386, 468, ...
8, 29, 52, 88, 124, 180, 224, 298, 360, 444, 518, 628, ...
12, 43, 78, 128, 180, 252, 316, 412, 498, 608, 706, ...
14, 57, 100, 162, 224, 316, 388, 508, 608, 738, 852, ...
...
		

Crossrefs

The Farey Diagrams Farey(m,n) are studied in A358298-A358307 and A358882-A358885, the Completed Farey Diagrams of order (m,n) in A358886-A358889.

Programs

  • Maple
    A005728 := proc(n) 1+add(numtheory[phi](i), i=1..n) ; end proc: # called F_n in the paper
    Amn:=proc(m,n) local a,i,j; # A331781 or equally A333295. Diagonal is A018805.
    a:=0; for i from 1 to m do for j from 1 to n do
    if igcd(i,j)=1 then a:=a+1; fi; od: od: a; end;
    # The present sequence is:
    Dmn:=proc(m,n) local d,t1,u,v,a; global A005728, Amn;
    a:=A005728(m)+A005728(n);
    t1:=0; for u from 1 to m do for v from 1 to n do
    d:=igcd(u,v); if d>=1 then t1:=t1 + (u+v)*numtheory[phi](d)/d; fi; od: od:
    a+2*t1-2*Amn(m,n); end;
    for m from 1 to 8 do lprint([seq(Dmn(m,n),n=1..20)]); od:

A358305 Triangle read by rows: T(n,k) (n>=0, 0 <= k <= n) = number of decreasing lines defining the Farey diagram Farey(n,k) of order (n,k).

Original entry on oeis.org

0, 0, 2, 0, 5, 10, 0, 9, 19, 32, 0, 14, 27, 47, 66, 0, 20, 40, 68, 96, 134, 0, 27, 51, 85, 118, 167, 204, 0, 35, 68, 112, 156, 217, 267, 342, 0, 44, 82, 137, 187, 261, 318, 408, 482, 0, 54, 103, 166, 229, 317, 384, 490, 581, 692, 0, 65, 120, 196, 266, 366, 441, 564, 664, 794, 904
Offset: 0

Views

Author

Keywords

Examples

			The full array T(n,k), n >= 0, k>= 0, begins:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, ...
0, 5, 10, 19, 27, 40, 51, 68, 82, 103, 120, 145, ...
0, 9, 19, 32, 47, 68, 85, 112, 137, 166, 196, 235, ...
0, 14, 27, 47, 66, 96, 118, 156, 187, 229, 266, ...
0, 20, 40, 68, 96, 134, 167, 217, 261, 317, 366, ...
0, 27, 51, 85, 118, 167, 204, 267, 318, 384, 441, ...
		

Crossrefs

Cf. A358298.
The Farey Diagrams Farey(m,n) are studied in A358298-A358307 and A358882-A358885, the Completed Farey Diagrams of order (m,n) in A358886-A358889.

Programs

  • Maple
    A005728 := proc(n) 1+add(numtheory[phi](i), i=1..n) ; end proc: # called F_n in the paper
    Amn:=proc(m,n) local a,i,j; # A331781 or equally A333295. Diagonal is A018805.
    a:=0; for i from 1 to m do for j from 1 to n do
    if igcd(i,j)=1 then a:=a+1; fi; od: od: a; end;
    DFD:=proc(m,n) local d,t1,u,v; global A005728, Amn;
    t1:=0; for u from 1 to m do for v from 1 to n do
    d:=igcd(u,v); if d>=1 then t1:=t1 + (u+v)*numtheory[phi](d)/d; fi; od: od:
    t1; end;
    for m from 0 to 8 do lprint([seq(DFD(m,n),n=0..20)]); od:
  • Mathematica
    T[n_, k_] := Sum[d = GCD[u, v]; If[d >= 1, (u+v)*EulerPhi[d]/d, 0], {u, 1, n}, {v, 1, k}];
    Table[T[n, k], {n, 0, 10}, {k, 0, n}] // Flatten (* Jean-François Alcover, Apr 18 2023 *)
Showing 1-7 of 7 results.