Class PrimeUtil

java.lang.Object
org.drip.numerical.common.PrimeUtil

public class PrimeUtil
extends java.lang.Object
Author:
Lakshmi Krishnamurthy
  • Constructor Summary

    Constructors
    Constructor Description
    PrimeUtil()  
  • Method Summary

    Modifier and Type Method Description
    static boolean IsPrime​(int n)
    Indicate if the specified Number is a Prime Number
    static double PrimeFactor​(int n)
    Compute the Prime Factor for a given Integer
    static java.util.TreeMap<java.lang.Integer,​java.lang.Integer> PrimeFactorMap​(int n)
    Retrieve the Map of Prime Factor Count for the given Number
    static int UglyNumber​(int n, int a, int b, int c)
    Find the n-th ugly number.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PrimeUtil

      public PrimeUtil()
  • Method Details

    • PrimeFactorMap

      public static final java.util.TreeMap<java.lang.Integer,​java.lang.Integer> PrimeFactorMap​(int n)
      Retrieve the Map of Prime Factor Count for the given Number
      Parameters:
      n - The Given Number
      Returns:
      Map of Prime Factor Count
    • IsPrime

      public static final boolean IsPrime​(int n)
      Indicate if the specified Number is a Prime Number
      Parameters:
      n - n
      Returns:
      The specified Number is Prime
    • PrimeFactor

      public static final double PrimeFactor​(int n) throws java.lang.Exception
      Compute the Prime Factor for a given Integer
      Parameters:
      n - The Integer
      Returns:
      Prime Factor for a given Integer
      Throws:
      java.lang.Exception - Thrown if the Inputs are Invalid
    • UglyNumber

      public static final int UglyNumber​(int n, int a, int b, int c) throws java.lang.Exception
      Find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.
      Parameters:
      n - n
      a - a
      b - b
      c - c
      Returns:
      The n-th Ugly Number
      Throws:
      java.lang.Exception - Thrown if the Inputs are Invalid