Global

Members

(constant) SolutionType :string

Enum for solution type values.
Properties:
Name Type Description
Linear string 'linear' – Solutions are x = mxn + px, y = myn + py
Unique string 'unique' – When a or b is 0, if a solution exists it's unique, e.g. 5x + 0y = 15 => solution is x = 3
AlwaysTrue string 'always-true' – Values of x and y don't matter, e.g. 0x + 0y = 0
None string 'none' – No solution, e.g. 8x + 6y = 1
Error string 'error' – Something went wrong
Source:
Type:
  • string

Methods

dioSolve(a, b, c) → {Solution}

Solves a linear Diophantine equation of the form: ax + by = c
Source:
Parameters:
Name Type Description
a number Coefficient for x
b number Coefficient for y
c number Right-side constant
Returns:
Type:
Solution
An object with all the result values.

gcd(a, b) → {GCD}

Finds the Greatest Common Divisor of a and b using the Euclidian algorithm
Source:
Parameters:
Name Type Description
a number Integer
b number Integer
Returns:
Type:
GCD
An object with properties g (gcd value) and steps (steps of the Euclidian algorithm)

Type Definitions

GCD

Properties:
Name Type Description
g number Value of GCD(a,b)
steps Array Steps of the Euclidian algorithm, last step first: [[an, bn], ..., [a0, b0]]
Source:
Type:
  • Object

Solution

Properties:
Name Type Description
solutionType SolutionType Type of solution found, see SolutionType for more information.
g number | null Value of GCD(a,b), null if error.
z Array | null Initial solution [x0, y0] found using the Euclidean algorithm when solution is linear, [x0, null] or [null, y0] when solution is unique, else null.
m Array | null Slope coefficients [mx, my] when solution is linear, else null.
p Array | null Intercepts [px, py] when solution is linear, else null.
Source:
Type:
  • Object