1
|
|
|
const millerRabin = require('../index') |
2
|
|
|
|
3
|
|
|
// const sieve = require('../src/sieve') |
4
|
|
|
|
5
|
|
|
// const primes = sieve(500000) |
6
|
|
|
|
7
|
|
|
// console.log(primes.length) |
8
|
|
|
|
9
|
|
|
describe('Test Miller-Rabin moduled', () => { |
10
|
|
|
it('2 is prime', () => { |
11
|
|
|
expect(millerRabin(2)).toBeTruthy() |
12
|
|
|
}) |
13
|
|
|
|
14
|
|
|
it('10 is composite', () => { |
15
|
|
|
expect(millerRabin(10)).toBeFalsy() |
16
|
|
|
}) |
17
|
|
|
|
18
|
|
|
it('53 is prime', () => { |
19
|
|
|
expect(millerRabin(53)).toBeTruthy() |
20
|
|
|
}) |
21
|
|
|
|
22
|
|
|
it('15487469 is prime', () => { |
23
|
|
|
expect(millerRabin(15487469)).toBeTruthy() |
24
|
|
|
}) |
25
|
|
|
|
26
|
|
|
it('1344513 is composite', () => { |
27
|
|
|
expect(millerRabin(1344513)).toBeFalsy() |
28
|
|
|
}) |
29
|
|
|
|
30
|
|
|
it('179425579 is prime', () => { |
31
|
|
|
expect(millerRabin(179425579)).toBeTruthy() |
32
|
|
|
}) |
33
|
|
|
|
34
|
|
|
it('1290318231923 is composite', () => { |
35
|
|
|
expect(millerRabin(1290318231923)).toBeFalsy() |
36
|
|
|
}) |
37
|
|
|
|
38
|
|
|
it('78817863267167 is prime', () => { |
39
|
|
|
expect(millerRabin(78817863267167)).toBeTruthy() |
40
|
|
|
}) |
41
|
|
|
|
42
|
|
|
it('4294967291 is prime', () => { |
43
|
|
|
expect(millerRabin(4294967291)).toBeTruthy() |
44
|
|
|
}) |
45
|
|
|
|
46
|
|
|
// primes.forEach(prime => { |
47
|
|
|
// it(`${prime} is prime`, () => { |
48
|
|
|
// expect(prime).toBeTruthy() |
49
|
|
|
// }) |
50
|
|
|
// }) |
51
|
|
|
}) |
52
|
|
|
|