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.

A274472 Number of iterations of the Collatz recursion required to reach a prime number.

Original entry on oeis.org

2, 0, 0, 1, 0, 1, 0, 2, 3, 1, 0, 2, 0, 1, 2, 3, 0, 4, 0, 2, 6, 1, 0, 3, 3, 1, 2, 2, 0, 3, 0, 4, 6, 1, 2, 5, 0, 1, 2, 3, 0, 7, 0, 2, 4, 1, 0, 4, 3, 4, 6, 2, 0, 3, 2, 3, 3, 1, 0, 4, 0, 1, 17, 5, 6, 7, 0, 2, 5, 3, 0, 6, 0, 1, 2, 2, 4, 3, 0, 4, 3, 1, 0, 8, 8, 1, 2
Offset: 1

Views

Author

Matthew Campbell, Jun 24 2016

Keywords

Comments

If n is prime then a(n)=0. If n is composite then a(n)=A280929(n). - Dmitry Kamenetsky, Jan 11 2017

Crossrefs

Programs

  • Mathematica
    Table[Length@ NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, ! PrimeQ@ # &] - 1, {n, 120}] (* Michael De Vlieger, Jun 26 2016 *)
  • PARI
    a(n) = my(i=0, k=n); while(!ispseudoprime(k), if(k%2==0, k=k/2, k=3*k+1); i++); i
    for(n=1, 87, print1(a(n), ", ")) \\ Felix Fröhlich, Jun 24 2016

Extensions

More terms from Felix Fröhlich, Jun 24 2016