Files
JavaScript/Maths/test/FermatPrimalityTest.test.js
Roland Hummel c5e44d498a A few suggestions / modifications / fixes
It seems you've accidentally swapped the implementation and the test file :)

The overall comment describing the algorithm (VERY nice doc, by the way) is not "proper" JSdoc => only one leading asterisk. It's generally considered good style to start a comment block (both JSdoc and regular comments) with a single, short sentence.

Further down, there were some git hiccups, most likely caused by merge conflicts?
2021-10-14 22:32:56 +02:00

20 lines
755 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, 50)).toBe(true)
expect(fermatPrimeCheck(10, 50)).toBe(false)
expect(fermatPrimeCheck(94286167, 50)).toBe(true)
expect(fermatPrimeCheck(83165867, 50)).toBe(true)
expect(fermatPrimeCheck(13268774, 50)).toBe(false)
expect(fermatPrimeCheck(13233852, 50)).toBe(false)
})
})