|
|
A338489
|
|
Let t be the closest triangular number to n! (in case n=2, the only case where we have a tie, take the larger t); then a(n) = n! - t.
|
|
2
|
|
|
0, 0, -1, 0, 3, 0, 17, -10, 134, 354, 1329, 4155, 3924, 19797, -94380, 787794, 2901480, -1907466, 38192984, 204434670, -304139881, 115819260, -12372023755, 6328965122, -397725674235, 1196412908415, 6734756394444, -6589458328753, 48604536424455, -1553224821563460, 2464230045322035
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,5
|
|
COMMENTS
|
It is conjectured that 0! = 1, 1! = 1, 3! = 6 and 5! = 120 are the only numbers that are both factorial (A000142) and triangular (A000217) numbers.
|
|
LINKS
|
|
|
FORMULA
|
a(n) = n! - m*(m+1)/2 where m = floor(sqrt(2 * n!)).
|
|
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
|
|
|
STATUS
|
approved
|
|
|
|