Java examples for java.lang:long
factorial calculation for long value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { long number = 2; System.out.println(factorial(number)); }// w w w . jav a 2 s .c o m public static long factorial(long number) { if (number <= 1) return 1; if (number == 2) return 2; return number * factorial(number - 1); } }