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.

A161638 The largest number of steps in Euclid's algorithm applied to A157807(n) and A157813(n).

Original entry on oeis.org

1, 1, 2, 2, 1, 1, 2, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 4, 3, 1, 1, 2, 2, 3, 3, 2, 2, 3, 2, 1, 1, 2, 3, 3, 2, 3, 4, 4, 3, 2, 2, 4, 3, 1, 1, 2, 2, 2, 4, 2, 3, 5, 3, 3, 3, 2, 2, 4, 4, 3, 3, 1, 1, 2, 3, 2, 3, 4, 3, 2, 2, 3, 3, 4, 3, 2, 2, 1, 1, 2, 3, 2, 3, 3, 3, 2
Offset: 1

Views

Author

Yalcin Aktar, Jun 15 2009

Keywords

Comments

The sequence of fractions is ordered as follows: 1/1, 2/1, 1/2, 1/3, 3/1, 4/1, 3/2, 2/3, 1/4, 1/5, 5/1,...

Examples

			a(8) = 3 because the algorithm applied to the pair (2,3) needs the steps 2 = 3 x 0 + 2 then 3 = 2 x 1 + 1 and 2 = 1 x 2 + 0.
		

Programs

  • Python
    from math import gcd
    def euclid_steps(a, b):
      if b == 0:
        return 0
      else:
        return 1 + euclid_steps(b, a % b)
    for s in range(2, 100, 2):
      for i in range(1, s):
        if gcd(i, s - i) != 1: continue
        print(euclid_steps(i, s - i))
      for i in range(s, 0, -1):
        if gcd(i, s + 1 - i) != 1: continue
        print(euclid_steps(i, s + 1 - i))
    # Hiroaki Yamanouchi, Oct 06 2014

Extensions

Partially edited by R. J. Mathar, Sep 23 2009
a(1) prepended and a(12)-a(87) added by Hiroaki Yamanouchi, Oct 06 2014