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.

A057691 Number of terms before entering cycle in trajectory of P under the 'Px+1' map, where P = n-th prime, or -1 if trajectory does not cycle.

Original entry on oeis.org

5, 13, 4, 10, 25, 11, 68, 14, 39, 34, 9, 4, 5, 5, 16, 16, 234, 23, 16, 5, 11, 5, 63, 116, 18, 18, 33, 288, 47, 29, 317, 14, 12, 61, 60, 6, 16, 10, 5, 14, 46, 5, 6, 15, 105, 4, 11, 48, 44, 5, 6, 10, 5, 55, 15, 14, 25, 17, 9, 16, 6, 7, 26, 5, 33, 46, 5, 16, 23, 13, 15, 11, 16, 14, 11
Offset: 2

Views

Author

N. J. A. Sloane, Oct 20 2000

Keywords

Comments

See A057684 for definition.

Examples

			For n=3, P=7: trajectory of 7 is 7, 50, 25, 5, 1, 8, 4, 2, 1, 8, 4, 2, 1, 8, 4, 2, 1, ..., which has maximal term 50, cycle length 4 and there are 4 terms before it enters the cycle.
		

Crossrefs

Programs

  • Mathematica
    Px1[p_,n_]:=Catch[For[i=1,iPaolo Xausa, Dec 11 2023 *)
  • Python
    from sympy import prime, primerange
    def a(n):
        P = prime(n)
        x, plst, traj, seen = P, list(primerange(2, P)), [], set()
        while x not in seen:
            traj.append(x)
            seen.add(x)
            x = next((x//p for p in plst if x%p == 0), P*x+1)
        return traj.index(x)
    print([a(n) for n in range(2, 82)]) # Michael S. Branicky, Dec 11 2023

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Nov 08 2000