SHARE
TWEET

Exercise6CalculateSum

g-stoyanov Dec 4th, 2012 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top