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

A182976 Denominators of fractions with the same position in A020652/A038567 and A182972/A182973.

Original entry on oeis.org

2, 3, 5, 23, 73, 143, 163, 235, 477, 1238, 4175, 4641, 7820, 11217, 25915, 37643, 95299, 576088, 1203677
Offset: 1

Views

Author

William Rex Marshall, Dec 16 2010

Keywords

Comments

The positions of the matching fractions are given in A182974.
The numerators of the matching fractions are given in A182975.
The initial (zeroth) term of A038567 is ignored.

Examples

			The matching fractions are 1/2, 1/3, 2/5, 9/23, 30/73, 59/143 ... (this is A182975/A182976).
		

References

  • S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.

Crossrefs

A245718 Integer part of sum of fractions A182972(k) / A182973(k) such that A182972(k) + A182973(k) = n.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 1, 0, 2, 0, 2, 0, 1, 1, 3, 1, 3, 1, 2, 1, 4, 1, 3, 2, 3, 2, 5, 1, 5, 3, 3, 2, 4, 2, 7, 3, 4, 3, 7, 2, 8, 3, 4, 3, 9, 3, 8, 3, 6, 4, 10, 3, 7, 4, 6, 5, 11, 3, 11, 5, 6, 6, 9, 4, 12, 6, 8, 4, 13, 4, 14, 6, 7, 7, 11, 4, 15, 6, 10, 7, 16
Offset: 3

Views

Author

Reinhard Zumkeller, Jul 30 2014

Keywords

Comments

A245718(n) = floor(A245677(n)/A245678(n)).

Examples

			 See A245677.
		

Crossrefs

Programs

  • Haskell
    a245718 n = a245677 n `div` a245678 n

A245677 Numerator of sum of fractions A182972(k) / A182973(k) such that A182972(k) + A182973(k) = n.

Original entry on oeis.org

1, 1, 11, 1, 79, 26, 339, 34, 5297, 62, 69071, 1165, 11723, 9844, 471181, 2625, 8960447, 73244, 8231001, 243757, 1031626241, 151100, 4178462515, 2651758, 10396147563, 11843614, 64166447971, 362476, 1989542332021, 97275764008, 1830230212061, 57286319768
Offset: 3

Views

Author

Reinhard Zumkeller, Jul 30 2014

Keywords

Comments

A182972(n) and A182973(n) provide an enumeration of positive rationals < 1 arranged by increasing sum of numerator and denominator then by increasing numerator;
a(n) = numerator(sum(A182972(k)/A182973(k): k such that A182972(k)+A182973(k)=n));
A245718(n) = floor(a(n)/A245678(n)).

Examples

			.     |  (num, den) = (A182973, A182973) | num(sum)| den(sum)|   [sum]
.   n |  num/den,   num + den = n        | A245677 | A245678 | A245718
. ----+----------------------------------+---------+---------+--------
.   3 |  1/2                             |       1 |       2 |       0
.   4 |  1/3                             |       1 |       3 |       0
.   5 |  1/4, 2/3                        |      11 |      12 |       0
.   6 |  1/5                             |       1 |       5 |       0
.   7 |  1/6, 2/5, 3/4                   |      79 |      60 |       1
.   8 |  1/7, 3/5                        |      26 |      35 |       0
.   9 |  1/8, 2/7, 4/5                   |     339 |     280 |       1
.  10 |  1/9, 3/7                        |      34 |      63 |       0
.  11 |  1/10, 2/9, 3/8, 4/7, 5/6        |    5297 |    2520 |       2
.  12 |  1/11, 5/7                       |      62 |      77 |       0
.  13 |  1/12, 2/11, 3/10, 4/9, 5/8, 6/7 |   69071 |   27720 |       2
.  14 |  1/13, 3/11, 5/9                 |    1165 |    1287 |       0
.  15 |  1/14, 2/13, 4/11, 7/8           |   11723 |    8008 |       1
.  16 |  1/15, 3/13, 5/11, 7/9           |    9844 |    6435 |       1 .
		

Crossrefs

Cf. A245678 (denominator), A182972, A182973, A245718.

Programs

  • Haskell
    import Data.Ratio ((%), numerator)
    a245677 n = numerator $ sum
       [num % den | num <- [1 .. div n 2], let den = n - num, gcd num den == 1]

A245678 Denominator of sum of fractions A182972(k) / A182973(k) such that A182972(k) + A182973(k) = n.

Original entry on oeis.org

2, 3, 12, 5, 60, 35, 280, 63, 2520, 77, 27720, 1287, 8008, 6435, 144144, 2431, 2450448, 46189, 3695120, 146965, 232792560, 96577, 1070845776, 1300075, 2974571600, 5014575, 11473347600, 215441, 332727080400, 31556720475, 486207248800, 20419054425
Offset: 3

Views

Author

Reinhard Zumkeller, Jul 30 2014

Keywords

Comments

A182972(n) and A182973(n) provide an enumeration of positive rationals < 1 arranged by increasing sum of numerator and denominator then by increasing numerator;
a(n) = denominator(sum(A182972(k)/A182973(k): k such that A182972(k)+A182973(k)=n));
A245718(n) = floor(A245677(n)/a(n)).

Examples

			See A245677.
		

Crossrefs

Cf. A245677 (numerator), A182972, A182973, A245718.

Programs

  • Haskell
    import Data.Ratio ((%), denominator)
    a245678 n = denominator $ sum
       [num % den | num <- [1 .. div n 2], let den = n - num, gcd num den == 1]

A182974 Numbers n for which A020652(n)/A038567(n) = A182972(n)/A182973(n).

Original entry on oeis.org

1, 2, 7, 158, 1617, 6211, 8058, 16765, 69093, 465988, 5297983, 6546724, 18588348, 38244610, 204136352, 430712111, 2760559191, 100878516991, 440393924631
Offset: 1

Views

Author

William Rex Marshall, Dec 16 2010

Keywords

Comments

Numerators of the matching fractions are given in A182975.
Denominators of the matching fractions are given in A182976.
The initial (zeroth) term of A038567 is ignored.

Examples

			a(1)=1, a(2)=2 and a(3)=7 because the 1st, 2nd and 7th fractions match in the following two sequences:
1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5 ... (A020652/A038567)
1/2, 1/3, 1/4, 2/3, 1/5, 1/6, 2/5, 3/4 ... (A182972/A182973)
		

References

  • S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.

Crossrefs

A182975 Numerators of fractions with the same position in A020652/A038567 and A182972/A182973.

Original entry on oeis.org

1, 1, 2, 9, 30, 59, 67, 97, 197, 513, 1729, 1922, 3239, 4646, 10734, 15592, 39474, 238623, 498579
Offset: 1

Views

Author

William Rex Marshall, Dec 16 2010

Keywords

Comments

The positions of the matching fractions are given in A182974.
The denominators of the matching fractions are given in A182976.
The initial (zeroth) term of A038567 is ignored.

Examples

			The matching fractions are 1/2, 1/3, 2/5, 9/23, 30/73, 59/143 ... (this is A182975/A182976).
		

References

  • S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.

Crossrefs

A365075 Decimal expansion of the initial irrational number of Cantor's diagonal argument: the k-th decimal digit of this constant is equal to the k-th decimal digit of A182972(k)/A182973(k).

Original entry on oeis.org

5, 3, 0, 6, 0, 6, 0, 0, 2, 0, 0, 4, 0, 1, 8, 0, 2, 0, 5, 3, 0, 2, 3, 8, 0, 4, 0, 1, 2, 7, 5, 7, 3, 6, 0, 6, 2, 5, 7, 0, 3, 5, 3, 6, 5, 0, 8, 7, 3, 3, 5, 6, 0, 6, 8, 6, 3, 2, 0, 1, 2, 3, 8, 0, 9, 3, 0, 1, 9, 6, 6, 4, 6, 9, 5, 2, 0, 6, 7, 2, 0, 3, 5, 0, 6, 9, 2, 0, 5
Offset: 0

Views

Author

Stefano Spezia, Aug 20 2023

Keywords

Examples

			0.5306060020040180205392380401375136062570353650803356... whose decimal expansion is given by the decimal digits on the diagonal of the list of rational numbers given by A182972 and A182973:
  .5000000000000000000...
  .3333333333333333333...
  .2500000000000000000...
  .6666666666666666667...
  .2000000000000000000...
  .1666666666666666667...
  .4000000000000000000...
  .7500000000000000000...
  .1428571428571428571...
  .6000000000000000000...
  .1250000000000000000...
  .2857142857142857143...
  .8000000000000000000...
  .1111111111111111111...
  .4285714285714285714...
  .1000000000000000000...
  ...
		

References

  • Andrew Hodges, Alan Turing: The Enigma, Princeton University Press, 2014. See p. 153.

Crossrefs

Programs

  • Mathematica
    t1={}; For[n=2, n <= 24, n++, AppendTo[t1, 1/(n-1)]; For[i=2, i <= Floor[(n-1)/2], i++, If[GCD[i, n-i] == 1, AppendTo[t1, i/(n-i)]]]]; (* A182972/A182973 *)
    a={}; For[i=1, i
    				
  • Python
    from itertools import count, islice
    from math import gcd
    def A365075_gen(): # generator of terms
        c = 1
        for n in count(2):
            for i in range(1,1+(n-1>>1)):
                if gcd(i,n-i)==1:
                    c *= 10
                    yield (i*c//(n-i))%10
    A365075_list = list(islice(A365075_gen(),30)) # Chai Wah Wu, Aug 28 2023

Extensions

Data checked by Chai Wah Wu and corrected by Stefano Spezia, Aug 29 2023

A023022 Number of partitions of n into two relatively prime parts. After initial term, this is the "half-totient" function phi(n)/2 (A000010(n)/2).

Original entry on oeis.org

1, 1, 1, 2, 1, 3, 2, 3, 2, 5, 2, 6, 3, 4, 4, 8, 3, 9, 4, 6, 5, 11, 4, 10, 6, 9, 6, 14, 4, 15, 8, 10, 8, 12, 6, 18, 9, 12, 8, 20, 6, 21, 10, 12, 11, 23, 8, 21, 10, 16, 12, 26, 9, 20, 12, 18, 14, 29, 8, 30, 15, 18, 16, 24, 10, 33, 16, 22, 12, 35, 12, 36, 18, 20, 18, 30, 12, 39, 16, 27, 20, 41, 12
Offset: 2

Views

Author

Keywords

Comments

The number of distinct linear fractional transformations of order n. Also the half-totient function can be used to construct a tree containing all the integers. On the zeroth rank we have just the integers 1 and 2: immediate "ancestors" of 1 and 2 are (1: 3,4,6 2: 5,8,10,12) etc. - Benoit Cloitre, Jun 03 2002
Moebius transform of floor(n/2). - Paul Barry, Mar 20 2005
Also number of different kinds of regular n-gons, one convex, the others self-intersecting. - Reinhard Zumkeller, Aug 20 2005
From Artur Jasinski, Oct 28 2008: (Start)
Degrees of minimal polynomials of cos(2*Pi/n). The first few are
1: x - 1
2: x + 1
3: 2*x + 1
4: x
5: 4*x^2 + 2*x - 1
6: 2*x - 1
7: 8*x^3 + 4*x^2 - 4*x - 1
8: 2*x^2 - 1
9: 8*x^3 - 6*x + 1
10: 4*x^2 - 2*x - 1
11: 32*x^5 + 16*x^4 - 32*x^3 - 12*x^2 + 6*x + 1
These polynomials have solvable Galois groups, so their roots can be expressed by radicals. (End)
a(n) is the number of rationals p/q in the interval [0,1] such that p + q = n. - Geoffrey Critzer, Oct 10 2011
It appears that, for n > 2, a(n) = A023896(n)/n. Also, it appears that a record occurs at n > 2 in this sequence if and only if n is a prime. For example, records occur at n=5, 7, 11, 13, 17, ..., all of which are prime. - John W. Layman, Mar 26 2012
From Wolfdieter Lang, Dec 19 2013: (Start)
a(n) is the degree of the algebraic number of s(n)^2 = (2*sin(Pi/n))^2, starting at a(1)=1. s(n) = 2*sin(Pi/n) is the length ratio side/R for a regular n-gon inscribed in a circle of radius R (in some length units). For the coefficient table of the minimal polynomials of s(n)^2 see A232633.
Because for even n, s(n)^2 lives in the algebraic number field Q(rho(n/2)), with rho(k) = 2*cos(Pi/k), the degree is a(2*l) = A055034(l). For odd n, s(n)^2 is an integer in Q(rho(n)), and the degree is a(2*l+1) = A055034(2*l+1) = phi(2*l+1)/2, l >= 1, with Euler's totient phi=A000010 and a(1)=1. See also A232631-A232633.
(End)
Also for n > 2: number of fractions A182972(k)/A182973(k) such that A182972(k) + A182973(k) = n, A182972(n) and A182973(n) provide an enumeration of positive rationals < 1 arranged by increasing sum of numerator and denominator then by increasing numerator. - Reinhard Zumkeller, Jul 30 2014
Number of distinct rectangles with relatively prime length and width such that L + W = n, W <= L. For a(17)=8; the rectangles are 1 X 16, 2 X 15, 3 X 14, 4 X 13, 5 X 12, 6 X 11, 7 X 10, 8 X 9. - Wesley Ivan Hurt, Nov 12 2017
After including a(1) = 1, the number of elements of any reduced residue system mod* n used by Brändli and Beyne is a(n). See the examples below. - Wolfdieter Lang, Apr 22 2020
a(n) is the number of ABC triples with n = c. - Felix Huber, Oct 12 2023

Examples

			a(15)=4 because there are 4 partitions of 15 into two parts that are relatively prime: 14 + 1, 13 + 2, 11 + 4, 8 + 7. - _Geoffrey Critzer_, Jan 25 2015
The smallest nonnegative reduced residue system mod*(n) for n = 1 is {0}, hence a(1) = 1; for n = 9 it is {1, 2, 4}, because 5 == 4 (mod* 9) since -5 == 4 (mod 9), 7 == 2 (mod* 9) and 8 == 1 (mod* 9). Hence a(9) = phi(9)/2 = 3. See the comment on Brändli and Beyne above. - _Wolfdieter Lang_, Apr 22 2020
		

References

  • G. Pólya and G. Szegő, Problems and Theorems in Analysis I (Springer 1924, reprinted 1972), Part Eight, Chap. 1, Sect. 6, Problems 60&61.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a023022 n = length [(u, v) | u <- [1 .. div n 2],
                                 let v = n - u, gcd u v == 1]
    -- Reinhard Zumkeller, Jul 30 2014
    
  • Magma
    [1] cat [EulerPhi(n)/ 2: n in [3..100]]; // Vincenzo Librandi, Aug 19 2018
  • Maple
    A023022 := proc(n)
        if n =2 then
            1;
        else
            numtheory[phi](n)/2 ;
        end if;
    end proc:
    seq(A023022(n),n=2..60) ; # R. J. Mathar, Sep 19 2017
  • Mathematica
    Join[{1}, Table[EulerPhi[n]/2, {n, 3, 100}]] (* adapted by Vincenzo Librandi, Aug 19 2018 *)
  • PARI
    a(n)=if(n<=2,1,eulerphi(n)/2);
    /* for printing minimal polynomials of cos(2*Pi/n) */
    default(realprecision,110);
    for(n=1,33,print(n,": ",algdep(cos(2*Pi/n),a(n))));
    
  • Python
    from sympy.ntheory import totient
    def a(n): return 1 if n<3 else totient(n)/2 # Indranil Ghosh, Mar 30 2017
    

Formula

a(n) = phi(n)/2 for n >= 3.
a(n) = (1/n)*Sum_{k=1..n-1, gcd(n, k)=1} k = A023896(n)/n for n>2. - Reinhard Zumkeller, Aug 20 2005
G.f.: x*(x - 1)/2 + (1/2)*Sum_{k>=1} mu(k)*x^k/(1 - x^k)^2. - Ilya Gutkovskiy, Apr 13 2017
a(n) = Sum_{d|n} moebius(n/d)*floor(d/2). - Michel Marcus, May 25 2021

Extensions

This was in the 1973 "Handbook", but then was dropped from the database. Resubmitted by David W. Wilson
Entry revised by N. J. A. Sloane, Jun 10 2012
Polynomials edited with the consent of Artur Jasinski by Wolfdieter Lang, Jan 08 2011
Name clarified by Geoffrey Critzer, Jan 25 2015

A038567 Denominators in canonical bijection from positive integers to positive rationals <= 1.

Original entry on oeis.org

1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16
Offset: 0

Views

Author

Keywords

Comments

n occurs phi(n) times (cf. A000010).
Least k such that phi(1) + phi(2) + phi(3) + ... + phi(k) >= n. - Benoit Cloitre, Sep 17 2002
Sum of numerator and denominator of fractions arranged by Cantor's ordering (1/1, 2/1, 1/2, 1/3, 3/1, 4/1, 3/2, 2/3, 1/4, 1/5, 5/1, 6/1, ...) with equivalent fractions removed. - Ron R. King, Mar 07 2009 [This applies to a(1, 2, ...) without initial term a(0) = 1 which could correspond to 0/1. - Editor's Note.]
Care has to be taken in considering the offset which may be 0 or 1 in related sequences (see crossrefs), e.g., A038568 & A038569 also have offset 0, in A038566 offset has been changed to 1. - M. F. Hasler, Oct 18 2021

Examples

			Arrange fractions by increasing denominator then by increasing numerator: 1/1, 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, ...: this is A038566/A038567.
		

References

  • S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.
  • Hans Lauwerier, Fractals, Princeton University Press, 1991, p. 23.

Crossrefs

A054427 gives mapping to Stern-Brocot tree.
Cf. A037162.

Programs

  • Haskell
    import Data.List (genericTake)
    a038567 n = a038567_list !! n
    a038567_list = concatMap (\x -> genericTake (a000010 x) $ repeat x) [1..]
    -- Reinhard Zumkeller, Dec 16 2013, Jul 29 2012
    
  • Maple
    with (numtheory): A038567 := proc (n) local sum, k; sum := 1: k := 2: while (sum < n) do: sum := sum + phi(k): k := k + 1: od: RETURN (k-1): end: # Ulrich Schimke (ulrschimke(AT)aol.com)
  • Mathematica
    a[n_] := (k = 0; While[ Total[ EulerPhi[ Range[k]]] <= n, k++]; k); Table[ a[n], {n, 0, 77}] (* Jean-François Alcover, Dec 08 2011, after Pari *)
    Flatten[Table[Table[n,{EulerPhi[n]}],{n,20}]] (* Harvey P. Dale, Mar 12 2013 *)
  • PARI
    a(n)=if(n<0,0,s=1; while(sum(i=1,s,eulerphi(i))
    				
  • Python
    from sympy import totient
    def a(n):
        s=1
        while sum(totient(i) for i in range(1, s + 1))Indranil Ghosh, May 23 2017
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def A002088(n): # based on second formula in A018805
        if n == 0:
            return 0
        c, j = 0, 2
        k1 = n//j
        while k1 > 1:
            j2 = n//k1 + 1
            c += (j2-j)*((A002088(k1)<<1)-1)
            j, k1 = j2, n//j2
        return n*(n-1)-c+j>>1
    def A038567(n):
        kmin, kmax = 0, 1
        while A002088(kmax) <= n:
            kmax <<= 1
        kmin = kmax>>1
        while True:
            kmid = kmax+kmin>>1
            if A002088(kmid) > n:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return kmax # Chai Wah Wu, Jun 10 2025

Formula

From Henry Bottomley, Dec 18 2000: (Start)
a(n) = A020652(n) + A020653(n) for all n > 0, e.g., a(1) = 2 = 1 + 1 = A020652(1) + A020653(1). [Corrected and edited by M. F. Hasler, Dec 10 2021]
n = a(A015614(n)) = a(A002088(n)) - 1 = a(A002088(n-1)). (End)
a(n) = A002024(A169581(n)). - Reinhard Zumkeller, Dec 02 2009
a(A002088(n)) = n for n > 1. - Reinhard Zumkeller, Jul 29 2012
a(n) = A071912(2*n+1). - Reinhard Zumkeller, Dec 16 2013
a(n) ~ c * sqrt(n), where c = Pi/sqrt(3) = 1.813799... (A093602). - Amiram Eldar, Dec 27 2024

Extensions

More terms from Erich Friedman

A182972 Numerators of positive rationals < 1 arranged by increasing sum of numerator and denominator then by increasing numerator.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 3, 1, 3, 1, 2, 4, 1, 3, 1, 2, 3, 4, 5, 1, 5, 1, 2, 3, 4, 5, 6, 1, 3, 5, 1, 2, 4, 7, 1, 3, 5, 7, 1, 2, 3, 4, 5, 6, 7, 8, 1, 5, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 7, 9, 1, 2, 4, 5, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 5, 7, 11, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 1, 3, 5, 7, 9, 11
Offset: 1

Views

Author

William Rex Marshall, Dec 16 2010

Keywords

Comments

A023022(n) and A245677(n) give number and numerator of sum of fractions a(k)/A182973(k) such that a(k) + A182973(k) = n. - Reinhard Zumkeller, Jul 30 2014

Examples

			Positive fractions < 1 listed by increasing sum of numerator and denominator, and by increasing numerator for equal sums:
1/2
1/3
1/4 2/3
1/5
1/6 2/5 3/4
1/7 3/5
1/8 2/7 4/5
1/9 3/7
1/10 2/9 3/8 4/7 5/6
1/11 5/7
1/12 2/11 3/10 4/9 5/8 6/7
1/13 3/11 5/9
1/14 2/13 4/11 7/8
1/15 3/13 5/11 7/9
1/16 2/15 3/14 4/13 5/12 6/11 7/10 8/9
1/17 5/13 7/11
1/18 2/17 3/16 4/15 5/14 6/13 7/12 8/11 9/10
1/19 3/17 7/13 9/11
(this is A182972/A182973).
		

References

  • S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.
  • R. K. Guy, Unsolved Problems in Number Theory (UPINT), Section D11.

Crossrefs

Cf. A182973 (denominators), A366191 (interleaved).
Essentially the same as A333856.

Programs

  • Haskell
    a182972 n = a182972_list !! (n-1)
    a182972_list = map fst $ concatMap q [3..] where
       q x = [(num, den) | num <- [1 .. div x 2],
                           let den = x - num, gcd num den == 1]
    -- Reinhard Zumkeller, Jul 29 2014
    
  • Maple
    t1:=[];
    for n from 2 to 40 do
    t1:=[op(t1),1/(n-1)];
    for i from 2 to floor((n-1)/2) do
       if gcd(i,n-i)=1 then t1:=[op(t1),i/(n-i)]; fi; od:
    od:
    t1;
  • Mathematica
    t1={}; For[n=2, n <= 40, n++, AppendTo[t1, 1/(n-1)]; For[i=2, i <= Floor[(n-1)/2], i++, If[GCD[i, n-i] == 1, AppendTo[t1, i/(n-i)]]]]; t1 // Numerator // Rest (* Jean-François Alcover, Jan 20 2015, translated from Maple *)
  • Pascal
    program a182972;
    var
      num,den,n: longint;
    function gcd(i,j: longint):longint;
    begin
      repeat
        if i>j then i:=i mod j else j:=j mod i;
      until (i=0) or (j=0);
      if i=0 then gcd:=j else gcd:=i;
    end;
    begin
      num:=1; den:=1; n:=0;
      repeat
        repeat
          inc(num); dec(den);
          if num>=den then
          begin
            inc(den,num); num:=1;
          end;
        until gcd(num,den)=1;
        inc(n); writeln(n,' ',num);
      until n=100000;
    end.
    
  • Python
    from itertools import count, islice
    from math import gcd
    def A182972_gen(): # generator of terms
        return (i for n in count(2) for i in range(1,1+(n-1>>1)) if gcd(i,n-i)==1)
    A182972_list = list(islice(A182972_gen(),10)) # Chai Wah Wu, Aug 28 2023

Extensions

Corrected by William Rex Marshall, Aug 12 2013
Showing 1-10 of 12 results. Next