OFFSET
1,1
COMMENTS
The initial term k is not counted as an element of the trajectory.
LINKS
Michel Lagneau, Table of n, a(n) for n = 1..1000
EXAMPLE
a(1)=3 because 2 = prime(1) in the trajectory 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1;
a(2)=6 because 3 = prime(2) is in the trajectory 6 -> 3 -> 10 -> ... -> 1;
a(3)=3 because 5 = prime(3) is in the trajectory 3 -> 10 -> 5 -> ... -> 1;
a(4)=9 because 7 = prime(4) is in the trajectory 9 -> 28 -> 14 -> 7 -> ... -> 1.
MAPLE
with(numtheory):
for n from 1 to 100 do:
jj:=0:
for k from 1 to 10^6 while(jj=0) do:
lst:={}:m:=k:ii:=0:it:=10^6:
for i from 1 to it while(ii=0) do:
if irem(m, 2)=0
then
m:=m/2:
else m:=3*m+1:
fi:
lst:=lst union {m}:
if m=1
then
ii:=1:
else
fi:
od:
n0:=nops(lst):
for j from 1 to n0 while(jj=0)do:
if ithprime(n)=lst[j]
then
jj:=1:
else fi:
od:
if jj=1 then printf(`%d, `, k):
else fi:
od:od:
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Nov 21 2015
STATUS
approved