mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00

- Add default number of iterations - Correct "corner cases" to "edge cases" - Make clear which bounds are inclusive and which are exclusive
20 lines
739 B
JavaScript
20 lines
739 B
JavaScript
import { fermatPrimeCheck, modularExponentiation } from '../FermatPrimalityTest'
|
|
|
|
describe('modularExponentiation', () => {
|
|
it('should give the correct output for all exponentiations', () => {
|
|
expect(modularExponentiation(38, 220, 221)).toBe(1)
|
|
expect(modularExponentiation(24, 220, 221)).toBe(81)
|
|
})
|
|
})
|
|
|
|
describe('fermatPrimeCheck', () => {
|
|
it('should give the correct output for prime and composite numbers', () => {
|
|
expect(fermatPrimeCheck(2, 35)).toBe(true)
|
|
expect(fermatPrimeCheck(10, 30)).toBe(false)
|
|
expect(fermatPrimeCheck(94286167)).toBe(true)
|
|
expect(fermatPrimeCheck(83165867)).toBe(true)
|
|
expect(fermatPrimeCheck(13268774)).toBe(false)
|
|
expect(fermatPrimeCheck(13233852)).toBe(false)
|
|
})
|
|
})
|