A factorized number representation for Fractran computations.

if factors = [ { base: 2, exponent: 3 }, { base: 3, exponent: 1 } ] then the represented number is 2^3 * 3^1 = 8 * 3 = 24

factors = [] means the number is 1

Constructors

Properties

factors: {
    base: number;
    exponent: number;
}[]

Type declaration

  • base: number
  • exponent: number

Methods

  • Divides this Fractran number by another by subtracting exponents in their prime factorizations.

    Parameters

    Returns null | FractranNumber

    The quotient if division is exact (no remainder), or null if division is not possible

  • Checks if this Fractran number equals another by comparing their prime factorizations.

    Parameters

    Returns boolean

    True if the numbers are equal, false otherwise

  • Creates a FractranNumber from a regular number by computing its prime factorization.

    Parameters

    • n: number

      The number to convert (must be a positive integer)

    Returns FractranNumber

    The FractranNumber representation with prime factorization

Generated using TypeDoc