Advertisement
dezlatanov

Untitled

Oct 10th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FactorialDivision {
  4.  
  5. static double getFactorial (int n){
  6. int factorial = 1;
  7. if (n == 0){
  8. factorial = 1;
  9. }else {
  10. for (int i = 1; i <= n; i++) {
  11. factorial *= i;
  12. }
  13. }
  14. return factorial;
  15. }
  16.  
  17. public static void main(String[] args) {
  18. Scanner scanner = new Scanner(System.in);
  19. int a = Integer.parseInt(scanner.nextLine());
  20. int b = Integer.parseInt(scanner.nextLine());
  21. if (b!=0) {
  22. double number = getFactorial(a) / getFactorial(b);
  23.  
  24. System.out.printf("%.2f", number);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement