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.
%I A057691 #20 Dec 12 2023 08:25:37 %S A057691 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, %T A057691 18,33,288,47,29,317,14,12,61,60,6,16,10,5,14,46,5,6,15,105,4,11,48, %U A057691 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 %N 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. %C A057691 See A057684 for definition. %H A057691 Michael S. Branicky, <a href="/A057691/b057691.txt">Table of n, a(n) for n = 2..10001</a> (terms 2..1000 from T. D. Noe) %e A057691 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. %t A057691 Px1[p_,n_]:=Catch[For[i=1,i<PrimePi[p],i++,If[Divisible[n,Prime[i]],Throw[n/Prime[i]]]];p*n+1]; %t A057691 Module[{nmax=100,m},Table[FirstPosition[m=NestWhileList[Px1[Prime[n],#]&,Prime[n],UnsameQ,All],Last[m]][[1]]-1,{n,2,nmax}]] (* _Paolo Xausa_, Dec 11 2023 *) %o A057691 (Python) %o A057691 from sympy import prime, primerange %o A057691 def a(n): %o A057691 P = prime(n) %o A057691 x, plst, traj, seen = P, list(primerange(2, P)), [], set() %o A057691 while x not in seen: %o A057691 traj.append(x) %o A057691 seen.add(x) %o A057691 x = next((x//p for p in plst if x%p == 0), P*x+1) %o A057691 return traj.index(x) %o A057691 print([a(n) for n in range(2, 82)]) # _Michael S. Branicky_, Dec 11 2023 %Y A057691 Cf. A057446, A057216, A057522, A057534, A057614. See also A033478, A057688, A057684, A057685, A057686, A057687, A057689, A057690. %K A057691 nonn,nice,easy %O A057691 2,1 %A A057691 _N. J. A. Sloane_, Oct 20 2000 %E A057691 More terms from Larry Reeves (larryr(AT)acm.org), Nov 08 2000