Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #8 Feb 28 2013 16:15:58
%S 0,0,0,0,0,1,2,0,0,1,1,0,0,2,3,0,0,3,1,0,0,1,2,0,0,1,1,0,0,3,4,0,0,2,
%T 1,2,0,1,2,0,0,1,1,1,0,2,3,0,0,2,1,0,0,1,2,0,0,2,1,1,0,4,5,0,0,3,1,1,
%U 0,1,2,0,0,1,1,1,0,2,3,0,0,5,1,0,0,1,2
%N For the Collatz (3x+1) iteration starting at n, number of integers k such that T(n,k) = T(n-1,k) +1 where T(n,k) is the k-th number of the trajectory (n is not counted).
%C T(n,k) is periodic, for example
%C T(6,3) = 10 and T(7,3) = 11;
%C T(10,3) = 16 and T(11,3) = 17,
%C …………..
%C T(6+4m, 3) = 10 + 6m and T(6+4m+1, 3) = 10 + 6m+1.
%C .................
%H Michel Lagneau, <a href="/A213185/b213185.txt">Table of n, a(n) for n = 1..10000</a>
%e a(7) = 2 because the Collatz iterations starting at 7 and 6 are :
%e T(7,k) =[7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
%e T(6,k) =[6, 3, 10, 5, 16, 8, 4, 2, 1] ; the number 7 is not counted
%e => T(7,3) = T(6,3) + 1 and T(7,5) = T(6,5) + 1, hence a(7) = 2.
%p nn:=200:T:=array(1..nn):U:=array(1..nn): aa:=1:
%p for i from 1 to nn do:
%p U[i]:=0:
%p od:
%p for n from 1 to nn do:
%p a:=0:k:=0:x:=n:
%p for i from 1 to 10^8 while (x>1) do:
%p if irem(x,2)=0 then
%p x := x/2:a:=a+1:k:=k+1:T[k]:=x:
%p else
%p x := 3*x+1: a := a+1: k:=k+1:T[k]:=x:
%p fi:
%p od:
%p it:=0:
%p for j from 1 to min(a,aa) do:
%p if T[j]=U[j]+1 then
%p it:=it+1:
%p else
%p fi:
%p od:
%p for m from 1 to a do:
%p U[m]:=T[m]:
%p od:
%p aa:=a: printf(`%d, `,it): od:
%Y Cf. A006577, A213186.
%K nonn
%O 1,7
%A _Michel Lagneau_, Feb 28 2013