Резултатът ми от домашното за цикли в Programming Basics в "Problem 5" не е верен
Problem 5.Calculate 1 + 1!/X + 2!/X2 + … + N!/XN
Write a program that, for a given two integer numbers n and x, calculates the sum S = 1 + 1!/x + 2!/x2 + … + n!/xn. Use only one loop. Print the result with 5 digits after the decimal point.
using System;
class CalculateSuperSum
{
static void Main()
{
int number1 = int.Parse(Console.ReadLine());
int number2 = int.Parse(Console.ReadLine());
double result = 1;
double sum1 = 1;
double sum2 = 1;
int num = 1;
double calc=0;
for (int index = 1; index <= number1; index++)
{
for (int i = 1; i <= num; i++)
{
sum1 = sum1 * i;
}
for (int i = 1; i <= num; i++)
{
if (num == 1)
{
continue;
}
sum2 = sum2 * number2;
}
num++;
calc = sum1 / sum2;
result +=calc;
}
Console.WriteLine("{0:0.00000}",result);
Console.WriteLine("Press Any Key");
Console.Read();
}
}