Java examples for java.lang:Math Number
Gets the factorial of a number
//package com.java2s; public class Main { /**//from w w w . j a v a 2 s . co m * Gets the factorial of a number * * @param num Number to start at * @return The factorial */ public static long factorial(long num) { if (num == 0) return 1; if (num == 2 || num == 1) { return num; } else { return num * factorial(num - 1); } } }