OFFSET
1,105
COMMENTS
Number of times that k iterations of n under the modified Collatz function yield k for some k. - The original name of the sequence.
This sequence uses the definition given in A014682: if n is odd, n -> (3n+1)/2 and if n is even, n -> n/2.
2 occurs first at a(105) and 3 occurs first at a(305). Do all nonnegative numbers appear? See A258828.
LINKS
EXAMPLE
For n = 5, the Collatz function does the following: 5 -> 8 -> 4 -> 2 -> 1. Here, for k = 1, 2, 3, 4, applying k iterations to 5 does not yield k. So a(5) = 0.
For n = 6, the Collatz function does the following: 6 -> 3 -> 5 -> 8 -> 4 -> 2 -> 1. After the 4th iteration, you arrive at 4. Since this is the only time this occurs, a(6) = 1.
MATHEMATICA
A258825[n_]:=Count[MapIndexed[{#1}==#2-1&, NestWhileList[If[OddQ[#], (3#+1)/2, #/2]&, n, #>1&]], True]; Array[A258825, 100] (* Paolo Xausa, Nov 06 2023 *)
PROG
(PARI) Tvect(n)=v=[n]; while(n!=1, if(n%2, k=(3*n+1)/2; v=concat(v, k); n=k); if(!(n%2), k=n/2; v=concat(v, k); n=k)); v
for(n=1, 200, d=Tvect(n); c=0; for(i=1, #d, if(d[i]==i-1, c++)); print1(c, ", "))
(Scheme)
(define (A258825 n) (let loop ((n n) (i 0) (s 0)) (if (= 1 n) (+ s (if (= i 1) 1 0)) (loop (A014682 n) (+ 1 i) (+ s (if (= i n) 1 0))))))
(define (A014682 n) (if (even? n) (/ n 2) (/ (+ n n n 1) 2)))
;; Antti Karttunen, Aug 18 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Derek Orr, Jun 11 2015
EXTENSIONS
Name changed by Antti Karttunen, Aug 18 2017
STATUS
approved