%I #46 Sep 08 2022 08:45:50
%S 1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,
%T 2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,4,2,1,1,4,
%U 4,2,1,1,4,4,2,1,1,4,4,2,1
%N Period 5 sequence: 1, 1, 4, 4, 2, ...
%C a(n) is the length of the period of the sequence (n^i) mod m, i=1,2,...; m = 10 or m = 5.
%H H. K. Funda, <a href="https://web.archive.org/web/20130308211724/http://www.freshersworld.com/content/how-find-out-last-digit-%E2%80%93-beginner">How to find out last digit</a>
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,1).
%F a(n) = (1 + floor((n mod 5)/2))^2 mod 7. - _Victor Dumbrava_, Jan 12 2018
%F G.f.: (1 + x + 4*x^2 + 4*x^3 + 2*x^4)/(1 - x^5). - _Iain Fox_, Jan 12 2018
%e a(0) = 1 because (0^i) mod 10 = 0, i=1,2,...;
%e a(2) = 4 since(2^1) mod 5 = 2, (2^2) mod 5 = 4, (2^3) mod 5 = 3, (2^4) mod 5 = 1, and (2^5) mod 5 = 2 again. So we have the sequence 2,4,3,1,... with period of length 4.
%t Flatten[Table[{1, 1, 4, 4, 2}, {20}]] (* _T. D. Noe_, Nov 20 2012 *)
%t CoefficientList[ Series[(-1 - x - 4x^2 - 4x^3 - 2x^4)/(x^5 -1), {x, 0, 104}], x] (* or *)
%t LinearRecurrence[{0, 0, 0, 0, 1}, {1, 1, 4, 4, 2}, 105] (* _Robert G. Wilson v_, Jan 20 2018 *)
%o (PARI) a(n) = [1, 1, 4, 4, 2][(n%5)+1] \\ _Iain Fox_, Jan 12 2018
%o (PARI) a(n) = ((1 + floor((n%5)/2))^2) % 7 \\ _Iain Fox_, Jan 12 2018
%o (PARI) first(n) = Vec((1 + x + 4*x^2 + 4*x^3 + 2*x^4)/(1 - x^5) + O(x^n)) \\ _Iain Fox_, Jan 12 2018
%o (Magma) &cat[ [1,1,4,4,2]: n in [0..23] ]; // _Vincenzo Librandi_, Jan 19 2018
%K nonn,easy
%O 0,3
%A _Washington Bomfim_, Nov 23 2010