login
Number of primes in orbit of 2n+1 in the 3x+1 problem.
3

%I #9 Aug 28 2016 18:18:34

%S 0,3,2,6,6,5,3,4,4,7,1,4,7,25,6,24,7,3,7,11,25,8,4,23,7,6,3,24,8,11,5,

%T 20,7,9,3,22,25,2,6,11,5,24,1,9,10,20,3,20,26,7,8,19,11,21,26,15,2,8,

%U 5,10,20,13,23,12,26,9,7,9,20,13,3,20,26,24,7,3,8,18,12,13,20,5,24,15,12

%N Number of primes in orbit of 2n+1 in the 3x+1 problem.

%H T. D. Noe, <a href="/A064684/b064684.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%e orbit(3) = 3->10->5->16->8->4->2->1. This contains 3 primes, 3, 5 and 2.

%o (ARIBAS): function orbit(n: integer): array; var stk: stack; begin stack_push(stk,n); while n <> 1 do if n mod 2 = 0 then n := n div 2; else n := 3*n + 1; end; stack_push(stk,n); end; return stack2array(stk); end; function primesfilter(ar: array): array; var j,k: integer; stk: stack; begin for j := 0 to length(ar) - 1 do k := prime32test(ar[j]); if k = 1 then stack_push(stk,ar[j]); end; end; return stack2array(stk); end; function a064684(maxarg: integer); var n: integer; begin for n := 1 to maxarg by 2 do write(length(primesfilter(orbit(n)))," "); end; end; a064684(190).

%K nonn,easy

%O 0,2

%A _Jon Perry_, Oct 10 2001

%E More terms from _Klaus Brockhaus_, Oct 13 2001