login
Last digit of n*2^n + 1.
2

%I #18 Jul 06 2024 23:04:51

%S 1,3,9,5,5,1,5,7,9,9,1,9,3,7,7,1,7,5,3,3,1,3,9,5,5,1,5,7,9,9,1,9,3,7,

%T 7,1,7,5,3,3,1,3,9,5,5,1,5,7,9,9,1,9,3,7,7,1,7,5,3,3,1,3,9,5,5,1,5,7,

%U 9,9,1,9,3,7,7,1,7,5,3,3

%N Last digit of n*2^n + 1.

%C This is a cyclic sequence of 20 numbers, using only 1,3,5,7 and 9 (4 times each).

%D James Cullen, Question 15897, Educational Times, Vol. 58 (December 1905), p. 534.

%D Richard K. Guy (2004), Unsolved Problems in Number Theory (3rd ed.), New York: Springer Verlag, pp. section B20, ISBN 0-387-20860-7.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Cullen_number">Cullen number</a>.

%H <a href="/index/Rec#order_13">Index entries for linear recurrences with constant coefficients</a>, signature (0,1,0,-1,1,1,-1,-1,1,0,-1,0,1).

%F a(n) = A010879(A002064(n)).

%F From _Chai Wah Wu_, Jul 06 2024: (Start)

%F a(n) = a(n-2) - a(n-4) + a(n-5) + a(n-6) - a(n-7) - a(n-8) + a(n-9) - a(n-11) + a(n-13) for n > 12.

%F G.f.: (-3*x^12 - 3*x^11 - 2*x^10 - 4*x^9 + x^8 - 5*x^6 + 2*x^5 + 3*x^4 - 2*x^3 - 8*x^2 - 3*x - 1)/((x - 1)*(x^4 + x^3 + x^2 + x + 1)*(x^8 - x^6 + x^4 - x^2 + 1)). (End)

%p lastDigit := proc(n)

%p return (n * 2^n + 1) mod 10;

%p end proc:

%p # Example usage

%p minN := 1; maxN := 10;

%p lastDigits := [seq(lastDigit(n), n = minN .. maxN)];

%p print(lastDigits);

%t lastDigit[n_] := Mod[n * 2^n + 1, 10]

%t (* Example usage *)

%t minN = 1; maxN = 10;

%t lastDigits = Table[lastDigit[n], {n, minN, maxN}]

%t Print[lastDigits]

%o (Python)

%o def last_digit(n):

%o return (n * 2**n + 1) % 10

%o # Example usage

%o min_n, max_n = 1, 10

%o last_digits = [last_digit(n) for n in range(min_n, max_n + 1)]

%o print(last_digits)

%o (PARI) a(n) = lift(Mod(n*2^n + 1, 10))

%Y Cf. A010879, A002064.

%Y Cf. A373098, A373100.

%K nonn,base,easy

%O 0,2

%A _Javier Rodríguez Ríos_, May 23 2024