system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Konrad |
How to make combinations and permutations?
C = ( (n +r -1)! ) / r! * (n - 1)!
or C = n! / (n - 1)
In gdscript there is no operator " ! "
Maybe there is an operator similar to “!”? It would help me.
Konrad | 2021-01-07 18:41
system
2
|
|
|
|
Reply From: |
poetastrophe |
You would use a loop and a method. I am only writing some pseudocode to get you along:
def factorial(n):
int product = 1
for int i = 1; i<n+1; ++i:
product = product*i
return product
then you don’t need the ! operator. For example writing n!/(n-1) = factorial(n)/(n-1)