This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

How to make combinations and permutations?

C = ( (n +r -1)! ) / r! * (n - 1)!
or C = n! / (n - 1)

In gdscript there is no operator " ! "

Godot version 3.2.4
in Engine by (41 points)

Maybe there is an operator similar to "!"? It would help me.

1 Answer

+1 vote
Best answer

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)

by (46 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.