Datasets:

ArXiv:
License:
File size: 377 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.Scanner;
public class Factorial {
	public static void main(String[] args) {
		System.out.print("Enter a number: ");
		Scanner input=new Scanner(System.in);
    		int num=input.nextInt();
		long ans=factorial(n);
		System.out.printf("Factorial of %d = %d", num, ans);
	}
	
	public static long factorial (int n){
		return (n==1||n==0)? 1: factorial(n-1)*n;
	}
}