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.

A383441 a(n) is the total of iterations needed in the binary GCD algorithm to compute gcd(n, k) for k = 0..n. The corresponding row of gcds is row n of A109004.

Original entry on oeis.org

0, 0, 0, 2, 1, 5, 5, 12, 5, 11, 12, 23, 13, 29, 27, 31, 17, 38, 26, 47, 31, 42, 51, 70, 35, 63, 64, 72, 62, 96, 69, 104, 49, 80, 84, 86, 64, 123, 103, 118, 77, 130, 94, 152, 115, 128, 151, 174, 90, 163, 138, 164, 144, 197, 157, 188, 144, 187, 206, 229, 157, 251
Offset: 0

Views

Author

Peter Luschny, May 16 2025

Keywords

Comments

The reference Python implementation is provided in the links. It is a variant of Algorithm B described by Knuth in TAOCP Vol. 2, potentially offering some speedup in Python.

References

  • Eric Bach and Jeffrey Shallit, Algorithmic Number Theory, section 4.7, p. 83.
  • D. E. Knuth, The Art of Computer Programming Second Edition. Vol. 2, Seminumerical Algorithms. Chapter 4.5.2 The greatest Common Divisor, Page 321, Algorithm B.

Crossrefs

Programs

  • Maple
    gcd_bin_count := proc(a, b) local count, odd, A, B, D;
    if a = 0 or a = b or b = 0 then return 0 fi; count := 0;
    odd := n -> n*2^(-padic:-ordp(n, 2));  # A000265
    A := odd(a); B := odd(b);
    while B <> A do count := count + 1;
       D := ifelse(A < B, B - A, A - B);
       B := ifelse(A < B, A, B);
       A := odd(D);
    od; count end:
    a := n -> local k; add(gcd_bin_count(n, k), k = 0..n):
    seq(a(n), n = 0..61);
  • Python
    # See the links.