The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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!)).
a(n) = A000142(n) - A000217(A129960(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
Sequence in context: A226158 A024040 A357811 * A009759 A127187 A057398
KEYWORD
sign,easy
AUTHOR
Ruediger Jehn, Nov 09 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 19 03:29 EDT 2024. Contains 372666 sequences. (Running on oeis4.)