Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DoubleFactorial {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- System.out.println(dblFact(n));
- }
- private static long dblFact(int n) {
- if (n < 0) {
- return -1;
- }
- if (n == 0 || n == 1) {
- return 1;
- }
- return n * dblFact(n - 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment