Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace laba_4
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Введите n,x");
  14. Calculate(Convert.ToInt32(Console.ReadLine()), Convert.ToDouble(Console.ReadLine()));
  15. Console.ReadKey();
  16. }
  17.  
  18. static int factorial(int i)
  19. {
  20. int result;
  21. if (i == 1)
  22. return 1;
  23. result = factorial(i - 1) * i;
  24. //Console.WriteLine(result);
  25. return result;
  26. }
  27.  
  28. public static double Task1(int n)
  29. {
  30. double result = (Math.Pow((-1),n))/factorial((n+1));
  31. //Console.WriteLine(result);
  32. return result;
  33. }
  34.  
  35. public static double Calculate(int n, double x)
  36. {
  37. double sum = 0;
  38. for (int i = 1; i <= n; i++)
  39. {
  40. sum += (Math.Pow((-1),n))/(Math.Pow(x, i) / i);
  41. }
  42. sum *= -1;
  43. Console.WriteLine(sum);
  44. return sum;
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement