OFFSET
0,3
COMMENTS
Numbers that are congruent to {0,1} mod 13. - Philippe Deléham, Oct 17 2001
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
From Colin Barker, May 14 2012: (Start)
a(n) = (11*(-1+(-1)^n)+26*n)/4.
a(n) = a(n-1) + a(n-2) - a(n-3) for n > 2.
G.f.: x*(1+12*x) / ((1-x)^2*(1+x)). (End)
EXAMPLE
a(3) = 14 because 14*14 = 196 = 1 (mod 13) and 14 = 1 (mod 13).
MAPLE
m:= 13; for n from 0 to 300 do if n^2 mod m = n mod m then print(n) fi od;
MATHEMATICA
Select[Range[0, 400], MemberQ[{0, 1}, Mod[#, 13]]&] (* Vincenzo Librandi, May 17 2012 *)
Select[Range[0, 400], Mod[#, 13]==PowerMod[#, 2, 13]&] (* or *) LinearRecurrence[ {1, 1, -1}, {0, 1, 13}, 60] (* Harvey P. Dale, Feb 07 2023 *)
PROG
(Magma) I:=[0, 1, 13]; [n le 3 select I[n] else Self(n-1)+Self(n-2)-Self(n-3): n in [1..70]]; // Vincenzo Librandi, May 17 2012
(PARI) a(n)=(11*(-1+(-1)^n)+26*n)/4 \\ Charles R Greathouse IV, Oct 16 2015
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jeremy Gardiner, Dec 28 2005
STATUS
approved