package com.nataraja.b;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Fact {
public static void main(String[] args) throws NumberFormatException, IOException {
System.out.println("Enter a Number:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
int f=fact(n);
System.out.println(f);
}
public static int fact(int n){
if(n==0)
return 1;
else
return fact(n-1)*n;
}
}
No comments:
Post a Comment