cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A342131 a(n) = n/2 + floor(n/4) if n is even, otherwise (3*n+1)/2.

This page as a plain text file.
%I A342131 #54 Sep 08 2022 08:46:26
%S A342131 0,2,1,5,3,8,4,11,6,14,7,17,9,20,10,23,12,26,13,29,15,32,16,35,18,38,
%T A342131 19,41,21,44,22,47,24,50,25,53,27,56,28,59,30,62,31,65,33,68,34,71,36,
%U A342131 74,37,77,39,80,40,83,42,86,43,89,45,92,46,95,48,98,49,101,51,104
%N A342131 a(n) = n/2 + floor(n/4) if n is even, otherwise (3*n+1)/2.
%C A342131 A permutation of the nonnegative integers related to the Collatz function (A014682).
%C A342131 Interspersion of A032766 and A016789. - _Michel Marcus_, Mar 04 2021
%H A342131 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>
%H A342131 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%H A342131 <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,1,0,1,0,-1).
%F A342131 a(n) = 9*n - 2*a(n-1) - 2*a(n-2) - 2*a(n-3) - a(n-4) - 17 for n >= 4.
%F A342131 a(n) = a(n-2) + a(n-4) - a(n-6).
%F A342131 a(n) = A006368(n+1) - 1.
%F A342131 G.f.: (x^4+2*x^3+3*x^2+x+2)*x/((x^2+1)*(x-1)^2*(x+1)^2). - _Alois P. Heinz_, Mar 01 2021
%F A342131 E.g.f.: (cos(x) + (6*x - 1)*cosh(x) + (2 + 3*x)*sinh(x))/4. - _Stefano Spezia_, Mar 02 2021
%F A342131 From _Bruno Berselli_, Mar 05 2021: (Start)
%F A342131 a(n) = (12*n + 4 - (3*n + 3 - (-1)^(n/2))*(1 + (-1)^n))/8. Therefore:
%F A342131 a(4*k)   = 3*k;
%F A342131 a(4*k+1) = 6*k + 2;
%F A342131 a(4*k+2) = 3*k + 1;
%F A342131 a(4*k+3) = 6*k + 5. (End)
%t A342131 a[n_] := If[EvenQ[n], n/2 + Floor[n/4], (3*n + 1)/2]; Array[a, 100, 0] (* _Amiram Eldar_, Mar 03 2021 *)
%t A342131 Table[(12 n + 4 - (3 n + 3 - (-1)^(n/2)) (1 + (-1)^n))/8, {n, 0, 70}] (* _Bruno Berselli_, Mar 05 2021 *)
%o A342131 (MATLAB)
%o A342131 function [a] = A342131(max_n)
%o A342131     for n = 1:max_n
%o A342131         m = n-1;
%o A342131         if floor(m/2) == m/2
%o A342131             a(n) = (m/2)+floor(m/4);
%o A342131         else
%o A342131             a(n) = (m*3+1)/2;
%o A342131         end
%o A342131     end
%o A342131 end
%o A342131 (PARI) a(n) = if (n%2, (3*n+1)/2, n/2 + n\4); \\ _Michel Marcus_, Mar 04 2021
%o A342131 (Magma) &cat [[3*k,6*k+2,3*k+1,6*k+5]: k in [0..20]] // _Bruno Berselli_, Mar 05 2021
%o A342131 (Python)
%o A342131 def A342131(n): return (3*n+1)//2 if n % 2 else n//2+n//4 # _Chai Wah Wu_, Mar 05 2021
%Y A342131 Cf. A014682, A006368.
%Y A342131 Cf. A032766, A016789.
%K A342131 nonn,easy
%O A342131 0,2
%A A342131 _Thomas Scheuerle_, Mar 01 2021