I have tried to make a simple factorial calculator in C#.
It works fine if the value entered is small enough( for instance, if I enter 5 it will print the correct output, 120);
However, if I enter 40, it will return me 0.
using System;
namespace FirstApplication
{
class Program
{
static void Main(string[] args)
{
int getInputN = Convert.ToInt32(Console.ReadLine());
static int getFactorial(int getInputN)
{
int total = 1;
for (int i = 1; i <= getInputN; i++)
{
total *= i;
}
return total;
}
Console.WriteLine(getFactorial(getInputN));
}
}
}