modlin: Modular Linear Equation Solver

Description Usage Arguments Details Value See Also Examples

View source: R/modular.R

Description

Solves the modular equation a x = b mod n.

Usage

1
modlin(a, b, n)

Arguments

a, b, n

integer scalars

Details

Solves the modular equation a x = b mod n. This eqation is solvable if and only if gcd(a,n)|b. The function uses the extended greatest common divisor approach.

Value

Returns a vector of integer solutions.

See Also

extGCD

Examples

1
2
3
4
modlin(14, 30, 100)             # 95 45
modlin(3, 4, 5)                 # 3
modlin(3, 5, 6)                 # []
modlin(3, 6, 9)                 # 2 5 8

Example output

[1] 95 45
[1] 3
NULL
[1] 2 5 8

numbers documentation built on May 15, 2021, 1:08 a.m.