Factorial function in AMPL

206 views
Skip to first unread message

Sourav Mondal

unread,
Feb 28, 2017, 3:57:38 AM2/28/17
to AMPL Modeling Language
Hi all,
I am trying to write a code for my ILP. I need to use a factorial function like this: factorial(n) = n*(n-1)*...*1.
What is the best possible method to implement this? There are several library functions for sin, cos etc., but, can't find one for the factorial.

Thanks,
Sourav

Robert Fourer

unread,
Mar 1, 2017, 9:30:34 AM3/1/17
to am...@googlegroups.com
factorial(n) can be computed by the AMPL expression

prod {i in 1..n} i

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages