Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FactorialDivision {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstNumber = Integer.parseInt(scanner.nextLine());
- int secondNumber = Integer.parseInt(scanner.nextLine());
- long firstNumberFactorial = calculateFactorial(firstNumber);
- long secondNumberFactorial = calculateFactorial(secondNumber);
- double result = firstNumberFactorial * 1.0 / secondNumberFactorial;
- System.out.printf("%.2f", result);
- }
- private static long calculateFactorial(int number) {
- long fact = 1;
- for (int i = 1; i <= number; i++) {
- fact = fact * i;
- }
- return fact;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment