Re: Factorial
"Konstantin L. Metlov" <[email protected]> Mon, 8 Aug 2016 14:52:31 +0300
| Newsgroups | gmane.comp.java.jel.general |
|---|---|
| Message-ID | <[email protected]> |
Yes, it is best to create an own function and export it to JEL namespace
via one of the "static library" classes.
Otherwise, since expressions have no syntax for looping, it is impossible
to code the integer factorial directly following its definition. However,
one can express in JEL a number of approximate formulas for it. Such as
Stirling formula:
round((sqrt(2*PI*n)*pow(n/E,n)))
, or even more precise Ramanujan formula:
round((sqrt(PI)*pow(n/E,n))*pow(((8*n + 4)*n + 1)*n + 1/30.,1./6.0))
. Both these formulas assume that java.lang.Math is exported to JEL
namespace as one of the static library classes.
With the best regards,
Konstantin.
> Hi,
> There is any possibility to calculate factorial function in JEL, i.e.:
> int x;int y;
> x = 5;y = "fact(x)";
> I have to create my own function ?
>
> Best,
> Ebtc
>
> _______________________________________________
> Help-jel mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/help-jel
>