OFFSET
1,1
EXAMPLE
149 belongs to this sequence as it is prime, it satisfies the Collatz conjecture in 23 (that is prime) steps; no other prime number greater than 149 and less than 163 satisfies the conjecture in a prime number of steps (151 does it in 15 steps; 157 in 36 steps); and the prime number 163 also satisfies it in 23 steps, just as 149 does.
PROG
(Python)
def length_collatz_chain(start):
i=0
while start != 1:
if (start % 2 == 0):
start = start / 2
else:
start = 3 * start + 1
i = i+1
return i
def is_prime(num):
if num == 1: return(0)
for k in range(2, num):
if (num % k) == 0:
return(0)
return(1)
collatz = []
nmax=10000
for i in range(nmax):
collatz.append(0)
collatz.append(0)
for i in range(nmax):
start=i+1
collatz[start]=length_collatz_chain(start)
lista_elem=[]
elem=[]
for i in range(1, nmax):
if is_prime(collatz[i]) and is_prime(i):
elem.append(i)
elem.append(collatz[i])
lista_elem.append(elem)
elem=[]
result=""
for i in range(len(lista_elem)-1):
if lista_elem[i][1]==lista_elem[i+1][1]:
result=result+str(lista_elem[i][0])+", "
print(result)
(PARI) nbs(n) = my(s); while(n>1, n=if(n%2, 3*n+1, n/2); s++); s; \\ A006577
lista(nn) = {vp = primes(nn); vs = select(x->isprime(nbs(x)), vp, 1); vpok = vector(#vs, k, prime(vs[k])); vpoks = vector(#vpok, k, nbs(vpok[k])); for (i=1, #vpoks-1, if (vpoks[i] == vpoks[i+1], print1(vpok[i], ", ")); ); } \\ Michel Marcus, Jul 27 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierandrea Formusa, Jul 07 2018
STATUS
approved