Advertisement
gospod1978

Methods-Factorial Division

Oct 13th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. namespace methods_exerci
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             long number = long.Parse(Console.ReadLine());
  11.             long divide = long.Parse(Console.ReadLine());
  12.             double result = Factorial(number) / Factorial(divide);
  13.             Console.WriteLine($"{result:f2}");
  14.         }
  15.  
  16.         static double Factorial(long number)
  17.         {
  18.             long sum2 = 1;
  19.  
  20.             if (number == 0)
  21.             {
  22.                 sum2 = 1;
  23.             }
  24.             else
  25.             {
  26.                 for (int i = 2; i <= number; i++)
  27.                 {
  28.                     sum2 *= (i);
  29.                 }  
  30.             }
  31.             return sum2;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement