SHARE
TWEET

Untitled

To6oKukata Oct 23rd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class FactorialExample2{  
  2.  static int factorial(int n){    
  3.   if (n == 0)    
  4.     return 1;    
  5.   else    
  6.     return(n * factorial(n-1));    
  7.  }    
  8.  public static void main(String args[]){  
  9.   int i,fact=1;  
  10.   int number=4;//It is the number to calculate factorial    
  11.   fact = factorial(number);  
  12.   System.out.println("Factorial of "+number+" is: "+fact);    
  13.  }  
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top