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 #11 Jan 30 2016 02:57:00
%S 3,10,5,36,18,9,154,77,1772,886,443,16392,8196,4098,2049,108598,54299,
%T 3312240,1656120,828060,414030,207015,17182246,8591123,833338932,
%U 416669466,208334733,22291816432,11145908216,5572954108,2786477054,1393238527,190873678200,95436839100,47718419550,23859209775
%N a(0) = 3; for n >= 1, if a(n-1) = 2*k, then a(n) = k, otherwise 1 + (A065091(n)*a(n-1)), where A065091(n) gives the n-th odd prime.
%C The original name of the sequence: P-adic Hailstone (or A033478): instead of 3, Prime[n] is used: a(n)=If[Mod[a(n - 1), 2] == 0, a(n - 1)/2, Prime(n + 1)*a(n - 1) + 1].
%D C. Pickover, Mazes for the Mind, St. Martin's Press, NY, 1992, p. 203-204.
%H Antti Karttunen, <a href="/A140948/b140948.txt">Table of n, a(n) for n = 0..150</a>
%F a(n) = If[Mod[a(n - 1), 2] == 0, a(n - 1)/2, Prime(n + 1)*a(n - 1) + 1].
%F a(0) = 3; for n >= 1, if a(n-1) = 2*k, then a(n) = k, otherwise 1 + (A065091(n)*a(n-1)). - _Antti Karttunen_, Jan 29 2016 after the Mathematica-code above and the original name of the sequence.
%t a[0] = 3; a[n_] := a[n] = If[Mod[a[n - 1], 2] == 0, a[n - 1]/2, Prime[n + 1]*a[n - 1] + 1]; Table[a[n], {n, 0, 30}]
%o (Scheme, with memoization-macro definec)
%o (definec (A140948 n) (cond ((zero? n) 3) ((even? (A140948 (- n 1))) (/ (A140948 (- n 1)) 2)) (else (+ 1 (* (A065091 n) (A140948 (- n 1)))))))
%o ;; _Antti Karttunen_, Jan 29 2016
%Y Cf. A033478, A065091.
%K nonn
%O 0,1
%A _Roger L. Bagula_ and _Gary W. Adamson_, Jul 24 2008
%E Offset corrected, name changed and more terms added by _Antti Karttunen_, Jan 29 2016