How do I calculate factorials in godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Anzol8

is there a simple way to do it?

:bust_in_silhouette: Reply From: Gluon

This would do it, but you seem to be asking questions rather than working these things out for yourself. This isnt the way to learn.

func factorial(n):
	var holdvalue = 0
	var boolis = true
	if n == 0 or n == 1:
		holdvalue = 1
	else:
		while n > 0:
			if boolis:
				boolis = false
				holdvalue = n
			else:
				holdvalue = holdvalue * n
			n = n-1

thanks, but I googled it and couldn’t find an answer, so I came hero to ask.

Anzol8 | 2022-11-27 22:04

There is no one way to learn and depending on the person and their needs sometimes they aren’t looking to learn but for a quick answer.

FireBlo33om | 2023-03-16 18:49