OFFSET
0,4
REFERENCES
L. E. Dickson, History of the Theory of Numbers. Carnegie Institute Public. 256, Washington, DC, Vol. 1, 1919; Vol. 2, 1920; Vol. 3, 1923, see vol. 1, p. 335.
R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics, Addison-Wesley, 2nd ed., 1994, ch. 4.
D. E. Knuth, The Art of Computer Programming, Addison-Wesley, section 4. 5. 2
LINKS
Alois P. Heinz, Antidiagonals n = 0..140, flattened
Marcelo Polezzi, A Geometrical Method for Finding an Explicit Formula for the Greatest Common Divisor, The American Mathematical Monthly, Vol. 104, No. 5 (May, 1997), pp. 445-446.
FORMULA
a(n, m) = a(m, n) = a(m, n-m) = a(m, n mod m), n >= m.
a(n, m) = n + m - n*m + 2*Sum_{k=1..m-1} floor(k*n/m).
Multiplicative in both parameters with a(p^e, m) = gcd(p^e, m). - David W. Wilson, Jun 12 2005
EXAMPLE
0;
1, 1;
2, 1, 2;
3, 1, 1, 3;
4, 1, 2, 1, 4;
5, 1, 1, 1, 1, 5;
6, 1, 2, 3, 2, 1, 6;
...
MATHEMATICA
a[n_, m_] := GCD[n, m]; Table[a[n - m, m], {n, 0, 10}, {m, 0, n}]//Flatten (* G. C. Greubel, Jan 04 2018 *)
PROG
(PARI) {a(n, m) = gcd( n, m)}
(PARI) {a(n, m) = local(x); n = abs(n); m = abs(m); if( !m, n, -2 * sum( k=1, m, x = k * n / m; x - floor( x) - 1/2))} /* Michael Somos, May 22 2011 */
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved