Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

[Enhancement] Add the possibility to get the factorial of a number #288

Closed
lpeyr opened this issue Jan 8, 2022 · 0 comments · Fixed by #290
Closed

[Enhancement] Add the possibility to get the factorial of a number #288

lpeyr opened this issue Jan 8, 2022 · 0 comments · Fixed by #290
Assignees
Labels
enhancement New feature or request roadmap Feature of the roadmap vNext Issues planed for the next version

Comments

@lpeyr
Copy link
Member

lpeyr commented Jan 8, 2022

Enhancement

Add the possibility to get the factorial of a number.

Other informations

Add a method in Maths.

Implementation:

public static int Factorial(int n)
{
	if (n == 1 || n == 0) return 1;
	int r = 1;
	
	for (int i = 1; i <= (n < 0 ? 0 - n : n); i++)
	{
		r *= i;
	}
	
	return (n < 0 ? 0 - r : r);
}
@lpeyr lpeyr added enhancement New feature or request vNext Issues planed for the next version roadmap Feature of the roadmap labels Jan 8, 2022
@lpeyr lpeyr self-assigned this Jan 8, 2022
@lpeyr lpeyr linked a pull request Jan 8, 2022 that will close this issue
@lpeyr lpeyr closed this as completed in #290 Jan 8, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request roadmap Feature of the roadmap vNext Issues planed for the next version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant