For loop to calculate factorials
Currently I have this set of code and its meant to calculate factorials. int numberInt = int.Parse(factorialNumberTextBox.Text); for (int i = 1; i < numberInt; i++) { numberInt = numberInt * i; } factorialAnswerTextBox.Text = numberInt.ToString(); For some reason it doesn't work and i have no clue why. For example i will input 3 and get the answer as -458131456 which seems really strange. Any help appreciated. Thanks int numberInt = int.Parse(factorialNumberTextBox.Text); int result = numberInt; for (int i = 1; i < numberInt; i++) { result = result * i; } factorialAnswerTextBox.Text = result