Advertisement
Guest User

Factorial division

a guest
Oct 14th, 2019
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 Factorial_division
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int first = int.Parse(Console.ReadLine());
  14.             int second = int.Parse(Console.ReadLine());
  15.  
  16.             FirstFactorial(first);
  17.             SecondFactorial(second);
  18.  
  19.             Console.WriteLine($"{FinalResult(first, second):F2}");
  20.         }
  21.         static int FirstFactorial(int a)
  22.         {
  23.             int current = 1;
  24.             int actual = 0;
  25.  
  26.             if (a >= 1)
  27.             {
  28.                 for (int num = a; num >= 1; num--)
  29.                 {
  30.                     actual = num;
  31.                     current = actual * current;
  32.                 }
  33.             }
  34.             return current;
  35.         }
  36.         static int SecondFactorial(int b)
  37.         {
  38.             int digit = 1;
  39.             int value = 0;
  40.  
  41.             if (b >= 1)
  42.             {
  43.  
  44.                 for (int num = b; num >= 1; num--)
  45.                 {
  46.                     value = num;
  47.                     digit = value * digit;
  48.                 }
  49.             }
  50.             return digit;
  51.         }
  52.         static double FinalResult(int a, int b)
  53.         {
  54.             double calculation = FirstFactorial(a) / SecondFactorial(b);
  55.             return calculation;
  56.         }
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement