A070983 Erroneous version of A078350.
1, 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
Offset: 1
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.
a055509 n = sum $ map a010051 $ takeWhile (> 2) $ iterate a006370 n -- Reinhard Zumkeller, Oct 08 2011
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
Join[{0}, Table[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &], ?PrimeQ] - 1, {n, 2, 94}]] (* _Jayanta Basu, Jun 15 2013 *)
A078350(n,c=0)={while(1>=valuation(n,2), isprime(n)&&c++; n=n*3+1);c} \\ M. F. Hasler, Dec 05 2017
a196871 n = a196871_list !! (n-1) a196871_list = filter (all (== 0) . map a010051 . takeWhile (> 2) . iterate a006370) [1..]
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Join[{1, 2}, Select[Range[3, 10000], Union[Drop[PrimeQ[Collatz[#]], -2]] == {False} &]] (* T. D. Noe, Jan 22 2013 *)
The sequence n, f(n), f(f(n)), ..., 1 for n = 7 is: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, which has six prime terms, more prime terms than for any n < 7. Hence 7 sets a record and so belongs to the sequence.
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]; high = 0; a = {}; For[j = 1, j <= 10^5, j++, k = g[j]; If[k > high, high = k; a = Append[a, j]]]; a (* Second program: *) With[{s = Array[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, #, # > 1 &], ?PrimeQ] &, 10^5]}, Map[FirstPosition[s, #][[1]] &, Union@ FoldList[Max, s]]] (* _Michael De Vlieger, Apr 21 2018 *)
A078350(n)=my(s=isprime(n)); while(n>1, if(n%2, n=(3*n+1)/2, n/=2); s+=isprime(n)); s r=0; for(n=2,1e9, t=A078350(n); if(t>r, r=t; print1(n", "))) \\ Charles R Greathouse IV, Apr 28 2015
The Collatz iteration of 7 produces 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, and 1, which are either even, prime, or 1.
a177000 n = a177000_list !! (n-1) a177000_list = filter (all (\x -> even x || a010051' x == 1) . (init . a070165_row)) a000040_list -- Reinhard Zumkeller, Apr 03 2012
Collatz[n_] := NestWhileList[If[EvenQ[ # ], #/2, 3#+1] &, n, #>1 &]; Reap[Do[p=Prime[n]; s=Most[Select[Collatz[p],OddQ]]; If[And@@PrimeQ[s], Sow[p]], {n,PrimePi[10^4]}]][[2,1]] oenQ[n_]:=AllTrue[DeleteCases[Most[NestWhileList[If[EvenQ[#],#/2, 3#+1]&,n, #>1&]], ?PrimeQ],EvenQ]; Select[Prime[Range[5000]], oenQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale, Dec 28 2014 *)
is(n)=isprime(n) && (n<23 || is((3*n+1)>>valuation(3*n+1,2))) \\ Charles R Greathouse IV, Jun 20 2013
a(6) = 7 because the Collatz trajectory of 7 is {7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1}, containing 6 primes {7, 11, 17, 13, 5, 2}, and 7 is the smallest positive integer for which exactly 6 primes occur via this trajectory.
import Data.List (elemIndex) import Data.Maybe (fromJust) a181921 = (+ 1) . fromJust . (`elemIndex` a078350_list) -- Reinhard Zumkeller, Apr 03 2012
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; nn = 50; t = Table[0, {nn}]; t[[1]] = 2; todo = nn - 1; n = 3; While[todo > 0, ps = Length[Select[Collatz[n], PrimeQ]]; If[ps <= nn && t[[ps]] == 0, t[[ps]] = n; todo--]; n = n + 2]; t (* T. D. Noe, Apr 02 2012 *) With[{lst=Table[Count[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&],?PrimeQ],{n, 71000}]},Table[Position[lst,k,1,1],{k,50}]//Flatten] (* _Harvey P. Dale, Sep 08 2018 *)
np(n)=my(t=1);while(n>2,t+=isprime(n);if(n%2,n+=n>>1+1,n>>=1));t v=vector(40);n=1;while(1,t=np(n++);if(t<=#v&&v[t]==0, v[t]=n; if(vecmin(v), return(v)))) \\ Charles R Greathouse IV, Apr 01 2012
a(9)=7 because the trajectory of 9 is 9 -> 28 -> 14 -> 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 and the 7 semiprimes of this trajectory are 9, 14, 22, 34, 26, 10 and 4.
Table[Count[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # != 1 &], k_ /; PrimeOmega@ k == 2], {n, 82}] (* Michael De Vlieger, Aug 11 2016 *)
print1(0, ", ");for(n=2, 100, s=n; t=0; while(s!=1, if(bigomega(s)==2 , t=t+1, t=t); if(s%2==0, s=s/2, s=(3*s+1)); if(s==1, print1(t", "))))
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.
a078440 n = a078440_list !! (n-1) a078440_list = filter notbp a196871_list where notbp x = m > 0 && x > 1 || m == 0 && notbp x' where (x',m) = divMod x 2 -- Reinhard Zumkeller, Oct 08 2011
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]; Select[Range[10^4], g[ # ] == 1 && ! IntegerQ[Log[2, # ]] &] pQ[n_]:=Count[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n, #>1&], ?PrimeQ] == 1; With[ {nn=10000},Complement[Select[Range[nn],pQ],2^Range[Floor[ Log[ 2,nn]]]]] (* _Harvey P. Dale, Oct 19 2011 *)
171917 is a prime which is the concatenation of 17, 19 and 17.
cat3:= proc(a,b,c) local alpha,beta; beta:= ilog10(c)+1; alpha:= beta + ilog10(b)+1; 10^alpha*a + 10^beta*b + c end proc: R:= NULL: count:= 0: q:= 2: while count < 100 do p:= q; q:= nextprime(q); v:= cat3(p,q,p); if isprime(v) then R:= R,v; count:= count+1; fi od: R; # Robert Israel, Jul 01 2025
f(n)=prime(n)*(10^(ceil(log(prime(n+1))/log(10))+ceil(log(prime(n))/log(10))))+ prime(n+1)*10^ceil(log(prime(n))/log(10))+prime(n); for(n=1,300, if(isprime(f(n))==1, print1(f(n),", ")))
a(9)=14 because the trajectory of 9 is 9 -> 28 -> 14 -> 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 and the 14 nonprimes of this trajectory are 9, 28, 14, 22, 34, 52, 26, 40, 20, 10, 16, 8, 4, and 1.
A267830[n_] := Count[NestWhileList[If[EvenQ@#, #/2, 3 # + 1] &, n, # != 1 &], ?(Not@PrimeQ@# &)] (* _JungHwan Min, Jan 24 2016 *)
for(n=1, 100, s=n; t=0; while(s!=1, if(!isprime(s) , t++); if(s%2==0, s=s/2, s=(3*s+1)); if(s==1, print1(t+1, ", "); ); ))
Comments