Here you can find the source of factorial(long num)
Parameter | Description |
---|---|
num | Number to start at |
public static long factorial(long num)
//package com.java2s; //License from project: Open Source License public class Main { /**//w ww . j a v a 2 s. c om * 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); } } }