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