MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / isValidP

Function isValidP

Maths/ShorsAlgorithm.js:78–81  ·  view source on GitHub ↗

* @function isValidP * @description Checks if A, B, and p fulfill A^p = mB + 1. * @param {BigInt} A * @param {BigInt} B * @param {BigInt} p * @returns Whether A, B, and p fulfill A^p = mB + 1.

(A, B, p)

Source from the content-addressed store, hash-verified

76 * @returns Whether A, B, and p fulfill A^p = mB + 1.
77 */
78function isValidP(A, B, p) {
79 // A^p = mB + 1 => A^p - 1 = 0 (mod B)
80 return (A ** p - 1n) % B === 0n
81}
82
83/**
84 * @function gcd

Callers 1

findPFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected