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.

A320028 a(n) is the first prime encountered when running the Collatz algorithm (halving and tripling steps) on the number n.

Original entry on oeis.org

2, 3, 2, 5, 3, 7, 2, 7, 5, 11, 3, 13, 7, 23, 2, 17, 7, 19, 5, 2, 11, 23, 3, 19, 13, 41, 7, 29, 23, 31, 2, 19, 17, 53, 7, 37, 19, 59, 5, 41, 2, 43, 11, 17, 23, 47, 3, 37, 19, 29, 13, 53, 41, 83, 7, 43, 29, 59, 23, 61, 31, 137, 2, 37, 19, 67, 17, 13, 53, 71, 7, 73, 37, 113, 19, 29, 59, 79, 5, 61, 41, 83, 2, 2, 43, 131
Offset: 2

Views

Author

Alessandro Polcini, Oct 03 2018

Keywords

Comments

A modified version of the halving and tripling Collatz algorithm, which stops as soon as the starting number becomes a prime (instead of stopping when the starting number reaches 1).
The plot of this sequence "completes" or "fills" the lower (empty) part of plot of A270570 and evolves in a similar fashion.

Examples

			a(4) is 2 because 4/2 = 2 and 2 is prime.
a(6) is 3 because 6/2 = 3 and 3 is prime.
a(15) is 23 because 15*3 + 1 = 46; 46/2 = 23 and 23 is prime.
a(18) is 7 because 18/2 = 9; 9*3 + 1 = 28; 28/2 = 14; 14/2 = 7 and 7 is prime.
		

Crossrefs

Programs

  • Java
    int collatzPrime(int i) {
        while(!BigInteger.valueOf(i).isProbablePrime(10) && i > 1) {
            if(i % 2 == 0)
                i /= 2;
            else
                i = 3 * i + 1;
        }
        return i;
    }
    
  • Mathematica
    Array[NestWhile[If[EvenQ@ #, #/2, 3 # + 1] &, #, ! PrimeQ@ # &] &, 86, 2] (* Michael De Vlieger, Nov 07 2018 *)
  • PARI
    a(n) = {while (!isprime(n), if (n % 2, n = 3*n+1, n = n/2);); n;} \\ Michel Marcus, Oct 28 2018

Formula

a(n) <= A087272(n). - Rémy Sigrist, Oct 08 2018