I'm kinda of having this error:
"System.IndexOutOfRangeException: Index was out of the Array"
When I change int=1
to long=1
it says it can't convert long
to int
.
I'm trying to save all output of N
into the Array and show at the end what is saved into arrays.
static void Main(string[] args)
{
int a = 0;
a = Convert.ToInt64(Console.ReadLine());
int[] array = new int[a];
if (a == 0)
{
Console.WriteLine("Falsche eingabe.");
}
else
{
long n = 1;
for (int i = 1; i <= array.Length; i++)
{
n *= i;
array[i] = n;
Console.WriteLine("N: " + i + " Fakultät von N: " + array[i]);
}
}
Console.ReadKey();
}