Advertisement
Qrist

Methods - Factorial division

Apr 15th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     public static void Main()
  5.     {
  6.         double first = int.Parse(Console.ReadLine());
  7.         double second = int.Parse(Console.ReadLine());
  8.  
  9.         double firstNumberFactorial = GetFactorial(first);
  10.         double secondNumberFactorial = GetFactorial(second);
  11.  
  12.         double result = firstNumberFactorial / secondNumberFactorial;
  13.  
  14.         Console.WriteLine($"{result:f2}");
  15.     }
  16.     public static double GetFactorial(double number)
  17.     {
  18.         double factorial = number;
  19.  
  20.         for (double i = number - 1; i >= 1; i--)
  21.         {
  22.             factorial *= i;
  23.         }
  24.  
  25.         return factorial;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement