Java factorial (recursive algorithm)

From , 4 Years ago, written in Java, viewed 49 times.
URL https://pastebin.vip/view/285e19f2
  1. /**
  2.  * 求阶乘
  3.  */
  4. public class Demo {
  5.         public static int factorial(int num) {
  6.                 int result = 1;
  7.                 if (num > 0) {
  8.                         result = num * factorial(num - 1);
  9.                 }
  10.                 return result;
  11.         }
  12.  
  13.         public static void main(String[] args) {
  14.                 System.out.println(factorial(3));
  15.         }
  16. }

Reply to "Java factorial (recursive algorithm)"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website