Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1.  
  2. static int fact(int b)
  3.  
  4. {
  5.  
  6. if(b <= 1)
  7.  
  8. //if the number is 1 then return 1
  9.  
  10. return 1;
  11.  
  12. else
  13.  
  14. //else call the same function with the value - 1
  15.  
  16. return b * fact(b-1);
  17.  
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement