%I #93 Jan 11 2023 09:15:05
%S 0,1,1,3,4,5,3,7,8,9,5,11,12,13,7,15,16,17,9,19,20,21,11,23,24,25,13,
%T 27,28,29,15,31,32,33,17,35,36,37,19,39,40,41,21,43,44,45,23,47,48,49,
%U 25,51,52,53,27,55,56,57,29,59,60,61,31,63,64,65,33,67
%N a(n) = n except a(4*n + 2) = 2*n + 1.
%C From _Federico Provvedi_, Nov 13 2018: (Start)
%C For n > 1, a(n) is also the cycle length generated by the cycle lengths of the digital roots, in base n, of the powers of k, with k > 0.
%C Example for n=10 (decimal base): for every h >= 0, the digital roots of 2^h generate a periodic cycle {1,2,4,8,7,5} with period 6; 3^h generates {1,3,9,9,9,9,...} so the periodic cycle {9} has period 1; 4^h generates the periodic cycle {1,4,7} with period 3; etc. So, for n=10 (decimal base representation) the sequence generated by the periods of the digital roots of powers of k (with k > 0) is also periodic {1,6,1,3,6,1,3,2,1} with period 9, hence a(10) = 9. (End)
%H Colin Barker, <a href="/A283971/b283971.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_08">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,2,0,0,0,-1).
%F a(2*n) = A022998(n), a(1+2*n) = 1 + 2*n.
%F a(n) = 2*a(n-4) - a(n-8).
%F From _Colin Barker_, Mar 19 2017: (Start)
%F G.f.: x*(1 + x + 3*x^2 + 4*x^3 + 3*x^4 + x^5 + x^6) / ((1 - x)^2*(1 + x)^2*(1 + x^2)^2).
%F a(n) = -((-1)^n - (-i)^n - i^n - 7)*n/8, where i = sqrt(-1).
%F (End)
%F a(n) = A060819(n) * periodic sequence of length 4: repeat [4, 1, 1, 1].
%F a(n) = a(n-4) + periodic sequence of length 4: repeat [4, 4, 2, 4].
%F From _Werner Schulte_, Jul 08 2018: (Start)
%F For n > 0, a(n) is multiplicative with a(p^e) = p^e for prime p >= 2 and e >= 0 except a(2^1) = 1.
%F Dirichlet g.f.: (1 - 1/2^s - 1/2^(2*s-1)) * zeta(s-1).
%F (End)
%F a(n) = n*(7 + cos(n*Pi/2) - cos(n*Pi) + cos(3*n*Pi/2))/8. - _Wesley Ivan Hurt_, Oct 04 2018
%F E.g.f.: (1/4)*x*(4*cosh(x) - sin(x) + 3*sinh(x)). - _Franck Maminirina Ramaharo_, Nov 13 2018
%F Sum_{k=1..n} a(k) ~ (7/16) * n^2. - _Amiram Eldar_, Nov 28 2022
%p seq(coeff(series(x*(1+x+3*x^2+4*x^3+3*x^4+x^5+x^6)/((1-x)^2*(1+x)^2*(1+x^2)^2), x,n+1),x,n),n=0..80); # _Muniru A Asiru_, Jul 20 2018
%t Table[If[Mod[n, 4] == 2, (n - 2)/2 + 1, n], {n, 67}] (* or *)
%t CoefficientList[Series[x (1 + x + 3 x^2 + 4 x^3 + 3 x^4 + x^5 + x^6)/((1 - x)^2*(1 + x)^2*(1 + x^2)^2), {x, 0, 67}], x] (* _Michael De Vlieger_, Mar 19 2017 *)
%t LinearRecurrence[{0, 0, 0, 2, 0, 0, 0, -1}, {0, 1, 1, 3, 4, 5, 3, 7}, 70] (* _Robert G. Wilson v_, Jul 23 2018 *)
%t Table[Length[FindTransientRepeat[(Length[FindTransientRepeat[Mod[#1^Range[b]-1,b-1]+1,2][[2]]]&)/@Range[2, 2*b], 2][[2]]], {b, 2, 100}] (* _Federico Provvedi_, Nov 13 2018 *)
%o (PARI) a(n)=if(n%4==2, n\4*2 + 1, n) \\ _Charles R Greathouse IV_, Mar 18 2017
%o (PARI) concat(0, Vec(x*(1 + x + 3*x^2 + 4*x^3 + 3*x^4 + x^5 + x^6) / ((1 - x)^2*(1 + x)^2*(1 + x^2)^2) + O(x^40))) \\ _Colin Barker_, Mar 19 2017
%o (GAP) a:=[0,1,1,3,4,5,3,7];; for n in [9..85] do a[n]:=2*a[n-4]-a[n-8]; od; a; # _Muniru A Asiru_, Jul 20 2018
%o (Python)
%o def A283971(n): return n if (n-2)&3 else n>>1 # _Chai Wah Wu_, Jan 10 2023
%Y Cf. A005408, A010121, A022998, A051176, A060819, A186646.
%K nonn,easy,mult
%O 0,4
%A _Paul Curtz_, Mar 18 2017