I want to write this equation:
1+(2/n!)+(3/n!)+...+(n/n!),
But the result is always equal to 1. Where is the wrong code? My code:
Console.Write("Please Enter Your Number: ");
int num = int.Parse(Console.ReadLine());
int fact = 1;
for (int i = num; i > 1; i--)
{
fact *= i;
}
Console.WriteLine("Fact= " + fact);
float result = 1;
for (int i = 2; i >= num; i++)
{
result += (i / fact);
}
Console.WriteLine("Result= " + result);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();