Factorial
3 posts • Page 1 of 1
Re: Factorial
As far as I know there is no single operator in Thyme which will calculate factorials. So, I think the best way to handle it is to create a function which calculates the factorial, and simply call the function like a subroutine with a single argument. In case you didn't know, factorial is calculated as follows:
n!=n×(n−1)×(n−2)...×2×1
where, n is a positive integer.
n!=n×(n−1)×(n−2)...×2×1
where, n is a positive integer.
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Factorial
press f10 to open the console, then type this:
scene.my.factorial = (n)=>{
n>2 ? {
n*scene.my.factorial(n-1)
} : {
2
}
}
then you can use factorials in that scene by typing scene.my.factorial(number).
scene.my.factorial = (n)=>{
n>2 ? {
n*scene.my.factorial(n-1)
} : {
2
}
}
then you can use factorials in that scene by typing scene.my.factorial(number).
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests