1
I’m not getting to be factorial expression, which is:
1 + (1/1! ) + (1/2! ) + (1/3! ) + ... + (1/n!)
Whereas the number n
is entered by the user.
My code:
Console.WriteLine("A expreção 1 + (1/1!) + (1/2!) + (1/3!) + ... + (1/n!)");
double fatorial = 1, s;
Console.WriteLine("Digite a quantidade de fatoação");
s = double.Parse(Console.ReadLine());
for (double n = 1; n <= s; n++)
{
fatorial = fatorial * n;
Console.WriteLine("############################################################################");
Console.WriteLine("A fatoração de " + n + " é: " + fatorial);
Console.WriteLine("");
Console.WriteLine("############################################################################");
Console.WriteLine("1 ÷ pela fatoração de " + 1 / fatorial);
Console.WriteLine("");
}
double conta = (1 / fatorial + fatorial);
Console.WriteLine("1 ÷ pela fatoração de " + conta);
Console.ReadKey();