Advertisement
deyanmalinov

08. Factorial Division

Feb 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.         public static void main(String[] args) {
  7.             Scanner scan = new Scanner(System.in);
  8.             double numOne = Double.parseDouble(scan.nextLine());
  9.             double secNum = Double.parseDouble(scan.nextLine());
  10.  
  11.             double devisRes = factor(numOne) / factor(secNum);
  12.             System.out.printf("%.2f", devisRes);
  13.  
  14.     }
  15.     public static double factor (double num){
  16.             double fac = 1;
  17.         for (int i = 2; i <= num; i++) {
  18.             fac *= i;
  19.  
  20.         }
  21.         return fac;
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement