OFFSET
0,2
COMMENTS
a(n) == Sum_{k>=0} k! (mod 5^n). Since k! mod 5^n is eventually zero, a(n) is well-defined.
In general, for every prime p, the p-adic integer x = Sum_{k>=0} k! is well-defined. To find the approximation up to p^n (n > 0) for x, it is enough to add k! for 0 <= k <= m and then find the remainder of the sum modulo p^n, where m = (p - 1)*(n + floor(log_p((p-1)*n))). This is because p^n divides (m+1)!
LINKS
Jianing Song, Table of n, a(n) for n = 0..1000
FORMULA
For n > 0, a(n) = (Sum_{k=0..m} k!) mod 5^n, where m = 4*(n + floor(log_5(4*n))).
EXAMPLE
For n = 7, since 5^7 divides 30!, we have a(7) = (Sum_{k=0..29} k!) mod 5^7 = 2814.
For n = 29, since 5^29 divides 125!, we have a(29) = (Sum_{k=0..124} k!) mod 5^29 = 173465698384532268439.
PROG
(PARI) a(n) = my(p=5); if(n==0, 0, lift(sum(k=0, (p-1)*(n+logint((p-1)*n, p)), Mod(k!, p^n))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Jianing Song, Feb 17 2021
STATUS
approved