Class MathUtil


  • public class MathUtil
    extends java.lang.Object
    Math Utilities.
    Author:
    Assaf Lehr
    • Constructor Summary

      Constructors 
      Constructor Description
      MathUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long factorial​(int n)
      Calculate the factorial of $n$.
      static int log2​(int n)
      Calculate the floor of the binary logarithm of $n$.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MathUtil

        public MathUtil()
    • Method Detail

      • factorial

        public static long factorial​(int n)
        Calculate the factorial of $n$.
        Parameters:
        n - the input number
        Returns:
        the factorial
      • log2

        public static int log2​(int n)
        Calculate the floor of the binary logarithm of $n$.
        Parameters:
        n - the input number
        Returns:
        the binary logarithm