Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Methods;
- import java.util.Scanner;
- public class Factorial_05 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstNumber = Integer.parseInt(scanner.nextLine());
- int secondNumber = Integer.parseInt(scanner.nextLine());
- //факториел на първото
- //факториел на второто
- //факториел на първото / факториел на второто -> печатам
- System.out.printf("%.2f", factorial(firstNumber) / factorial(secondNumber));
- }
- public static double factorial (int number) {
- double fact = 1;
- for (int i = 1; i <= number ; i++) {
- fact = fact * i;
- }
- return fact;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment