SHOW:
|
|
- or go back to the newest paste.
| 1 | package exe4_Methods; | |
| 2 | ||
| 3 | import java.util.Scanner; | |
| 4 | ||
| 5 | public class prob8_Factorial_Division {
| |
| 6 | public static void main(String[] args) {
| |
| 7 | Scanner scanner = new Scanner(System.in); | |
| 8 | int num1 = Integer.parseInt(scanner.nextLine()); | |
| 9 | int num2 = Integer.parseInt(scanner.nextLine()); | |
| 10 | int factorialNum1 = getFactorial(num1); | |
| 11 | int factorialNum2 = getFactorial(num2); | |
| 12 | double divisionFactorials = 1.0 * factorialNum1 / factorialNum2; | |
| 13 | System.out.printf("%.2f", divisionFactorials);
| |
| 14 | } | |
| 15 | ||
| 16 | private static int getFactorial(int numbers) {
| |
| 17 | int factorial = 1; | |
| 18 | for (int j = numbers; j >= 1; j--) {
| |
| 19 | factorial *= j; | |
| 20 | } | |
| 21 | return factorial; | |
| 22 | } | |
| 23 | } | |
| 24 |