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

* [CREATE] Problem 28 solution for Project Euler * [UPDATE] Added an explanation for the formula used in the algorithm * [CREATE] Added Problem 35 for Project-Euler * [UPDATE] Little typo in the error string * [UPDATE] Some algorithm changes * [UPDATE] Fix test string * [UPDATE] Change prime numbers generator to import a standard sieve algorithm. * [UPDATE] Change sieve algorithm implementation and now the solution works well. Also added some optimizations
19 lines
644 B
JavaScript
19 lines
644 B
JavaScript
import { problem35 } from '../Problem035.js'
|
|
|
|
describe('checking circular primes', () => {
|
|
it('should be invalid input if number is negative', () => {
|
|
expect(() => problem35(-3)).toThrowError('Invalid input')
|
|
})
|
|
it('should be invalid input if number is 0', () => {
|
|
expect(() => problem35(0)).toThrowError('Invalid input')
|
|
})
|
|
// Project Euler Condition Check
|
|
test('if the number is equal to 100 result should be 13', () => {
|
|
expect(problem35(100)).toBe(13)
|
|
})
|
|
// Project Euler Challenge Check
|
|
test('if the number is equal to one million result should be 55', () => {
|
|
expect(problem35(1000000)).toBe(55)
|
|
})
|
|
})
|