login
Primes in A006577.
5

%I #14 Mar 26 2019 06:48:10

%S 7,2,5,3,19,17,17,7,7,23,5,13,13,109,29,11,11,11,19,19,19,19,107,107,

%T 17,17,17,17,113,113,113,7,41,41,103,103,23,23,23,23,23,23,23,67,31,

%U 31,31,31,31,31,13,13,13,13,101,101,13,13,127,83,127,47,47,109,47,109,109

%N Primes in A006577.

%H Robert Israel, <a href="/A066903/b066903.txt">Table of n, a(n) for n = 1..10000</a>

%e a(1) = 7 because the first prime in A006577 is A006577(3) = 7.

%p N:= 1000; # to get the first N terms

%p Collatz:= proc(n) option remember;

%p if n::even then 1+Collatz(n/2)

%p else 1+Collatz(3*n+1)

%p fi

%p end proc;

%p Collatz(1):= 0;

%p count:= 0;

%p for i from 1 while count < N do

%p x:= Collatz(i);

%p if isprime(x) then count:= count+1; A[count]:= x fi;

%p od:

%p seq(A[i],i=1..N); # _Robert Israel_, Jun 01 2014

%t M = 100;

%t Collatz[n_] := Collatz[n] = If[EvenQ[n], 1+Collatz[n/2], 1+Collatz[3n+1]];

%t Collatz[1] = 0;

%t count = 0;

%t For[i = 1, count < M, i++, x = Collatz[i]; If[PrimeQ[x], count = count+1; a[count] = x]];

%t Array[a, M] (* _Jean-François Alcover_, Mar 26 2019, after _Robert Israel_ *)

%Y Cf. A006577.

%K nonn,look

%O 1,1

%A K. B. Subramaniam (kb_subramaniambalu(AT)yahoo.com), Dec 20 2001

%E More terms from _Sascha Kurz_, Mar 23 2002

%E Offset corrected by _Robert Israel_, Jun 01 2014