Class Factorial

java.lang.Object
topics.introduction.Factorial

public class Factorial extends Object
To calculate the factorial of a number
Author:
vicegd
  • Constructor Details

    • Factorial

      public Factorial()
  • Method Details

    • factorialOK

      public int factorialOK(int n)
      Calculates the factorial of a number with a recursive algorithm
      Parameters:
      n - Value used to calculate the factorial
      Returns:
      Factorial of n
    • factorialWrong

      public int factorialWrong(int n)
      Calculates the factorial of a number with a recursive algorithm It has a problem: if n is negative, it never stops
      Parameters:
      n - Value used to calculate the factorial
      Returns:
      Factorial of n