[go: up one dir, main page]

login
A070975
Number of steps to reach 1 in `3x+1' (or Collatz) problem starting with prime(n).
5
1, 7, 5, 16, 14, 9, 12, 20, 15, 18, 106, 21, 109, 29, 104, 11, 32, 19, 27, 102, 115, 35, 110, 30, 118, 25, 87, 100, 113, 12, 46, 28, 90, 41, 23, 15, 36, 23, 67, 31, 31, 18, 44, 119, 26, 119, 39, 70, 13, 34, 83, 52, 21, 65, 122, 78, 29, 42, 16, 42, 60, 117, 37, 86, 130, 37, 24
OFFSET
1,2
FORMULA
a(n) = A006577(prime(n)). - Michel Marcus, Sep 07 2014
MATHEMATICA
ns[n_]:=Length[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n, #!=1&]]-1; ns/@ Prime[Range[70]] (* Harvey P. Dale, Jul 29 2014 *)
PROG
(PARI) for(n=2, 100, s=prime(n); t=0; while(s!=1, t++; if(s%2==0, s=s/2, s=3*s+1); if(s==1, print1(t, ", "); ); ))
(Python)
from sympy import prime
def a006577(n):
if n==1: return 0
x=0
while True:
if n%2==0: n//=2
else: n = 3*n + 1
x+=1
if n<2: break
return x
def a(n): return a006577(prime(n))
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 05 2017
CROSSREFS
Cf. A006577.
Sequence in context: A299556 A282978 A125719 * A265763 A064024 A284085
KEYWORD
easy,nonn
AUTHOR
Benoit Cloitre, May 17 2002
STATUS
approved