Answers for "factorial symbol in java"

1

factorial number in java

int num1 = 6; 
 int num2 = 1;
    for(int a = 1; a<=num1; a++) {
        num2 = num2 * a;
    }
        System.out.println(num2);
Posted by: Guest on June-04-2021
1

Factorial program in java

// Factorial program using recursion
public class FactorialRecursion
{
   public static void main(String[] args)
   {
      int factorial = 1;
      int number = 6;
      factorial = factorialFunction(number);
      System.out.println("Factorial of " + number + " is : " + factorial);
   }
   static int factorialFunction(int num)
   {
      if(num == 0)
      {
         return 1;
      }
      else
      {
         return(num * factorialFunction(num - 1));
      }
   }
}
Posted by: Guest on December-29-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language