Advertisement
g-stoyanov

Exercise6CalculateSum

Dec 4th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. class Exercise6CalculateSum
  5. {
  6.     static void Main()
  7.     {
  8.         int n = int.Parse(Console.ReadLine());
  9.         Numerics.BigRational x = int.Parse(Console.ReadLine());
  10.         Numerics.BigRational result = 1;
  11.         Numerics.BigRational pow = x;
  12.         Numerics.BigRational factorial = 1;
  13.         for (int i = 1; i <= n; i++)
  14.         {
  15.             factorial = factorial * i;
  16.             result = result + (factorial / pow);
  17.             pow = pow * x;
  18.         }
  19.         Console.WriteLine(result);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement