Calculate Factorial of a Number using Recursion

public class FactorialUsingRecursion {
public static void main(String args[]) throws NumberFormatException, IOException{
System.out.println("Enter the number: ");
BufferedReader br=
new BufferedReader(new InputStreamReader(;
int a = Integer.parseInt(br.readLine());
int result= fact(a);
System.out.println("Factorial of the number is: " + result);
static int fact(int b)
if(b <= 1)
return 1;
return b * fact(b-1);

1 comment :

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes


Copyright © Rough Record. Designed by OddThemes