Here you can find the source of factorial(int integer)
Parameter | Description |
---|---|
integer | Integer to have is factorial |
public static long factorial(int integer)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . jav a2 s . co m * Compute the factorial of an integer * * @param integer * Integer to have is factorial * @return integer! */ public static long factorial(int integer) { if (integer < 1) { return 0; } if (integer < 3) { return integer; } long factorial = integer; integer--; while (integer > 1) { factorial *= integer; integer--; } return factorial; } }