Java examples for java.lang:Math Algorithm
factorial recursive function
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int n = 2; System.out.println(factorial(n)); }/* w w w . j a v a2 s. c om*/ public static int factorial(int n) { if (n == 0) return 1; return n * factorial(n - 1); } }