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.

Showing 1-6 of 6 results.

A078350 Number of primes in {n, f(n), f(f(n)), ..., 1}, where f is the Collatz function defined by f(x) = x/2 if x is even; f(x) = 3x + 1 if x is odd.

Original entry on oeis.org

0, 1, 3, 1, 2, 3, 6, 1, 6, 2, 5, 3, 3, 6, 4, 1, 4, 6, 7, 2, 1, 5, 4, 3, 7, 3, 25, 6, 6, 4, 24, 1, 7, 4, 3, 6, 7, 7, 11, 2, 25, 1, 8, 5, 4, 4, 23, 3, 7, 7, 6, 3, 3, 25, 24, 6, 8, 6, 11, 4, 5, 24, 20, 1, 7, 7, 9, 4, 3, 3, 22, 6, 25, 7, 2, 7, 6, 11, 11, 2, 5, 25, 24, 1, 1, 8, 9, 5, 10, 4, 20, 4, 3, 23, 20
Offset: 1

Views

Author

Joseph L. Pe, Dec 23 2002

Keywords

Comments

Number of primes in the trajectory of n under the 3x+1 map (i.e., the number of primes until the trajectory reaches 1, including 2 once). - Benoit Cloitre, Dec 23 2002
a(A196871(n)) = 0. - Reinhard Zumkeller, Oct 08 2011
a(A181921(n)) = n and a(m) <> n for m < A181921(n). - Reinhard Zumkeller, Apr 03 2012

Examples

			3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1; in this trajectory 3, 5, 2 are primes hence a(3) = 3. - _Benoit Cloitre_, Dec 23 2002
The finite sequence n, f(n), f(f(n)), ..., 1 for n = 12 is 12, 6, 3, 10, 5, 16, 8, 4, 2, 1, which has three prime terms. Hence a(12) = 3.
		

Crossrefs

Programs

  • Haskell
    a078350 n = sum $ map a010051 $ takeWhile (> 1) $ iterate a006370 n  -- Reinhard Zumkeller, Oct 08 2011
  • Maple
    a:= proc(n) option remember; `if`(n=1, 0,
         `if`(isprime(n), 1, 0)+a(`if`(n::even, n/2, 3*n+1)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Nov 04 2024
  • Mathematica
    f[n_] := n/2 /; Mod[n, 2] == 0 f[n_] := 3 n + 1 /; Mod[n, 2] == 1 g[n_] := Module[{i, p}, i = n; p = 0; While[i > 1, If[PrimeQ[i], p = p + 1]; i = f[i]]; p]; Table[g[n], {n, 1, 100}]
    Table[Count[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#!=1&],?PrimeQ],{n,100}] (* _Harvey P. Dale, Aug 29 2012 *)
  • PARI
    for(n=2,500,s=n; t=0; while(s!=1,if(isprime(s)==1,t=t+1,t=t); if(s%2==0,s=s/2,s=(3*s+1)); if(s==1,print1(t,","); ); )) \\ Benoit Cloitre, Dec 23 2002
    
  • PARI
    a(n)=my(s=isprime(n));while(n>1,if(n%2,n=(3*n+1)/2,n/=2);s+=isprime(n));s \\ Charles R Greathouse IV, Apr 28 2015
    
  • PARI
    A078350(n,c=n>1)={while(1>=valuation(n,2), isprime(n)&&c++; n=n*3+1);c} \\ M. F. Hasler, Dec 05 2017
    

Formula

a(n) = A055509(n) + 1 for n > 1.
a(n) = 1 when n > 1 is in A000079, i.e., a power of 2. - Benoit Cloitre, Dec 20 2017

Extensions

Edited by N. J. A. Sloane, Jan 17 2009 at the suggestion of R. J. Mathar

A055509 Number of odd primes in sequence obtained in 3x+1 (or Collatz) problem starting at n.

Original entry on oeis.org

0, 0, 2, 0, 1, 2, 5, 0, 5, 1, 4, 2, 2, 5, 3, 0, 3, 5, 6, 1, 0, 4, 3, 2, 6, 2, 24, 5, 5, 3, 23, 0, 6, 3, 2, 5, 6, 6, 10, 1, 24, 0, 7, 4, 3, 3, 22, 2, 6, 6, 5, 2, 2, 24, 23, 5, 7, 5, 10, 3, 4, 23, 19, 0, 6, 6, 8, 3, 2, 2, 21, 5, 24, 6, 1, 6, 5, 10, 10, 1, 4, 24, 23, 0, 0, 7, 8, 4, 9, 3, 19, 3, 2, 22, 19
Offset: 1

Views

Author

G. L. Honaker, Jr., Jun 30 2000

Keywords

Crossrefs

Programs

  • Haskell
    a055509 n = sum $ map a010051 $ takeWhile (> 2) $ iterate a006370 n -- Reinhard Zumkeller, Oct 08 2011
    
  • Maple
    g:= proc(n) option remember;
       local x;
       x:= 3*n+1;
       x:= x/2^padic:-ordp(x,2);
       if isprime(n) then procname(x)+1 else procname(x) fi
    end proc:
    g(1):= 0:
    seq(g(n/2^padic:-ordp(n,2)),n=1..100); # Robert Israel, Dec 05 2017
  • Mathematica
    Join[{0}, Table[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &], ?PrimeQ] - 1, {n, 2, 94}]] (* _Jayanta Basu, Jun 15 2013 *)
  • PARI
    A078350(n,c=0)={while(1>=valuation(n,2), isprime(n)&&c++; n=n*3+1);c} \\ M. F. Hasler, Dec 05 2017

Formula

a(n) = A078350(n) - 1 for n > 1.
a(A196871(n)) = 0. - Reinhard Zumkeller, Oct 08 2011
From Robert Israel, Dec 05 2017: (Start)
If n is odd, a(n) = a(3*n+1) + A010051(n).
If n is even, a(n) = a(n/2). (End)

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Aug 09 2001

A221475 Odd numbers having no odd primes in their Collatz (3x+1) trajectory.

Original entry on oeis.org

1, 21, 85, 341, 453, 909, 1365, 1813, 5461, 7281, 9669, 21845, 29013, 29125, 38835, 45839, 54327, 58197, 58253, 68759, 77667, 81491, 87381, 103139, 116053, 116501, 122237, 154709, 154737, 155341, 183357, 232789, 233013, 257551, 275037, 310385, 310669, 325965
Offset: 1

Views

Author

T. D. Noe, Feb 14 2013

Keywords

Comments

Sequence A196871 contains these terms and even numbers that are 2^k times terms in this sequence.

Crossrefs

Cf. A196871.

Programs

  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; t = {1}; n = 1; While[Length[t] < 50, n = n + 2; If[Union[Drop[PrimeQ[Collatz[n]], -2]] == {False}, AppendTo[t, n]]]; t

A078440 Numbers n with property that n is not a power of 2 and the finite sequence n, f(n), f(f(n)), ...., 1 in the Collatz (or 3x + 1) problem contains exactly one prime. (The earliest "1" is meant.)

Original entry on oeis.org

21, 42, 84, 85, 168, 170, 336, 340, 341, 453, 672, 680, 682, 906, 909, 1344, 1360, 1364, 1365, 1812, 1813, 1818, 2688, 2720, 2728, 2730, 3624, 3626, 3636, 5376, 5440, 5456, 5460, 5461, 7248, 7252, 7272, 7281, 9669
Offset: 1

Views

Author

Joseph L. Pe, Dec 31 2002

Keywords

Comments

f(n) = n/2 if n is even, = 3n + 1 if n is odd. Powers 2^n trivially have exactly one prime in n, f(n), f(f(n)), ..., 2, 1, namely 2 and so are excluded from the sequence.
A055509(a(n)) = 0; A078350(a(n)) <= 1.

Examples

			n, f(n), f(f(n)), .... for n = 21 is: 21, 64, 32, 16, 8, 4, 2, 1, which has exactly one prime, that is, 2. Hence 21 belongs to the sequence.
		

Crossrefs

A006370; subsequence of A196871 (with binary powers).

Programs

A362959 Numbers k such that the Collatz orbit that begins with k does not contain an odd prime afterwards.

Original entry on oeis.org

4, 5, 8, 16, 21, 32, 42, 64, 84, 85, 113, 128, 168, 170, 227, 256, 336, 340, 341, 453, 512, 672, 680, 682, 906, 909, 1024, 1344, 1360, 1364, 1365, 1812, 1813, 1818, 2048, 2417, 2688, 2720, 2728, 2730, 3624, 3626, 3636, 3637, 4096, 5376, 5440, 5456, 5460, 5461, 7248
Offset: 1

Views

Author

Hugo Pfoertner, May 18 2023

Keywords

Examples

			a(11) = 113, because its Collatz orbit 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2 avoids odd primes.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[4, 7500], NoneTrue[Rest@ NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, #, # > 1 &], And[OddQ[#], PrimeQ[#]] &] &] (* Michael De Vlieger, May 18 2023 *)
  • PARI
    cm(k) = {while (k>1, k=if(k%2,3*k+1,k/2); if(isprime(k),break)); k};
    for (k=3, 7500, if(cm(k)==2, print1(k,", ")))

A319227 a(n) is the number of twin primes in the Collatz trajectory of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 2, 0, 2, 0, 1, 1, 0, 2, 0, 0, 0, 2, 2, 0, 0, 1, 0, 1, 2, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 1, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 0, 2, 2, 1, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 1, 2, 0, 2, 1, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2
Offset: 1

Views

Author

Michel Lagneau, Sep 14 2018

Keywords

Comments

Conjecture: a(n) <=2.
For a(n) = 2, the corresponding twin primes are (5, 7) and (11, 13) or (11, 13) and (17, 19).
This sequence is generalizable: let a(n, p, p+2q) be the number of pairs of primes of form (p, p+2q) in the Collatz trajectory of n, q = 1, 2,... It is conjectured that a(n, p, p+2q) < =2. (see the table below).
+----------------+---------------------------------+
| pairs of prime | pairs of prime numbers |
| numbers | in the Collatz trajectory |
| | when a(n, p, p+2q) = 2 |
+----------------+---------------------------------+
| (p, p+2) | (5, 7) and (11, 13) |
| | or (11, 13) and (17, 19) |
+----------------+---------------------------------+
| (p, p+4) | (7, 11) and (13, 17) |
+----------------+---------------------------------+
| (p, p+6) | (41, 47) and (47, 53) |
| | or (47, 53) and (97, 103) |
| | or (47, 53) and (587, 593) |
+----------------+---------------------------------+
| (p, p+8) | (23, 31) and (53, 61) |
+----------------+---------------------------------+
| (p, p+10) | (61, 71) and (73, 83) |
| | or (61, 71) and (283, 293) |
| | or (61, 71) and (577, 587) |
+----------------+---------------------------------+
| (p, p+12) | (71, 83) and (251, 263) |
| | or (251, 263) and (467, 479) |
| | or (251, 263) and (479, 491) |
| | or (251, 263) and (1607, 1619) |
+----------------+---------------------------------+
| (p, p+14) | No results for n <= 10^6 |
+----------------+---------------------------------+
...................................................

Examples

			a(7) = 2 because the Collatz trajectory of 7 is 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 with two twin primes: (5, 7) and (11, 13).
		

Crossrefs

Programs

  • Maple
    nn:=10^8:
    for n from 1 to 100 do:
       m:=n:lst:={}:
          for i from 1 to nn while(m<>1) do:
            if irem(m, 2)=0
             then
             m:=m/2:
             else
             lst:=lst union {m}:m:=3*m+1:
           fi:
         od:
         n0:=nops(lst):it:=0:
         for j from 1 to n0-1 do:
         if isprime(lst[j]) and isprime(lst[j+1]) and lst[j+1]=lst[j]+2
         then it:=it+1:else fi:
          od:
        printf(`%d, `,it):
        od:
Showing 1-6 of 6 results.