Advertisement
patrik5

Problem 05

Mar 24th, 2014
1,268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class CalculateFaktorial
  7. {
  8. static void Main()
  9. {
  10.  
  11. Console.WriteLine("Enter N=");
  12. int n = int.Parse(Console.ReadLine());
  13. Console.WriteLine("Enter X=");
  14. int X = int.Parse(Console.ReadLine());
  15. double rezult =1.00;
  16. double FaktSum = 1.00;
  17. double tempDelitel=1.00;
  18. for (int i = 1; i<=n; i++)
  19. {
  20. // double factorial = 0.0;
  21. FaktSum*= i;
  22. tempDelitel = tempDelitel * n;
  23. rezult +=FaktSum / tempDelitel;
  24.  
  25. }
  26.  
  27. Console.WriteLine(rezult);
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement