A057690 Length of cycle in trajectory of P under the 'Px+1' map, where P = n-th prime, or -1 if trajectory does not cycle.
3, 3, 4, 4, 3, 4, 4, 5, 4, 6, 3, 4, 4, 6, 5, 5, 3, 4, 6, 3, 6, 5, 5, 4, 4, 5, 6, 4, 4, 8, 5, 4, 5, 5, 5, 3, 4, 6, 4, 6, 4, 8, 3, 5, 6, 4, 7, 5, 4, 5, 7, 4, 6, 4, 6, 6, 6, 3, 12, 4, 5, 5, 6, 3, 4, 4, 4, 5, 5, 4, 7, 6, 4, 5, 9, 5, 3, 4, 4, 6, 3, 8, 4, 6, 5, 6, 3, 5, 6, 6, 8, 5, 5, 6, 7, 5, 5, 4, 3, 4, 5, 5, 5, 5, 4
Offset: 2
Examples
For n=4, 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.
Links
- Michel Marcus, Table of n, a(n) for n = 2..10000
Crossrefs
Programs
-
Mathematica
Px1[p_,n_]:=Catch[For[i=1,i
Paolo Xausa, Dec 11 2023 *) -
PARI
f(m, p) = {forprime(q=2, precprime(p-1), if (! (m % q), return (m/q));); m*p+1;} a(n) = {my(p=prime(n), x=p, list = List()); listput(list, x); while (1, x = f(x, p); for (i=1, #list, if (x == list[i], return (#list - i + 1));); listput(list, x););} \\ Michel Marcus, Jan 12 2021
-
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 len(traj) - traj.index(x) print([a(n) for n in range(2, 107)]) # Michael S. Branicky, Dec 11 2023
Extensions
More terms from Larry Reeves (larryr(AT)acm.org), Nov 08 2000
Corrected by T. D. Noe, Apr 02 2008
Comments