Simple Java program to calculate double factorial (n!!) of given non-negative integer.
import java.util.Scanner; // 2018 TheFlyingKeyboard and released under MIT License // theflyingkeyboard.net public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int n; System.out.println("Enter a number: "); n = reader.nextInt(); //Reads integer from keyboard System.out.println("Double Factorial of: " + n + " is equal to: " + doubleFactorial(n)); } private static int doubleFactorial(int n){ int doubleFact = 1; for(int i = n; i > 1; i -= 2){ doubleFact *= i; } return doubleFact; } }