mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
solution: Project Euler 35 (#1201)
* [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
This commit is contained in:
18
Project-Euler/test/Problem035.test.js
Normal file
18
Project-Euler/test/Problem035.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user