OFFSET
0,5
COMMENTS
FORMULA
EXAMPLE
a(7) = 7! - 100*101 / 2 = 5040 - 5050 = -10.
MATHEMATICA
ctn[n_]:=Module[{c=Floor[(Sqrt[1+8n!]-1)/2], tr1, tr2, trp}, tr1=(c(c+1))/2; tr2=((c+1)(c+2))/2; trp=Nearest[{tr1, tr2}, n!]; n!-trp]; Join[{0, 0, -1}, Flatten[Array[ctn, 30, 3]]] (* Harvey P. Dale, Aug 22 2021 *)
PROG
(PARI) a(n) = my(m = sqrtint(2*n!)); n! - m*(m+1)/2; \\ Michel Marcus, Nov 09 2020
(Python)
from math import factorial, isqrt
def A338489(n): return (f:=factorial(n))-((m:=isqrt(f<<1))*(m+1)>>1) # Chai Wah Wu, Aug 04 2022
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Ruediger Jehn, Nov 09 2020
STATUS
approved