Skip to content

Add tests for Project Euler Problem 5 + minor refactor #1691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b7309f0
📦 NEW: Added solution for ProjectEuler-007
omkarnathparida Oct 7, 2022
d3a3b33
🐛 FIX: Spelling mistake fixes
omkarnathparida Oct 7, 2022
e9b5a6a
👌 IMPROVE: changed variable name from `inc` to `candidateValue` and t…
omkarnathparida Oct 7, 2022
e99c722
👌 IMPROVE: Modified the code
omkarnathparida Oct 7, 2022
5ac898f
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 10, 2022
0f9f1ba
👌 IMPROVE: Added test case for ProjectEuler Problem001
omkarnathparida Oct 10, 2022
3caad5c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 15, 2022
b7584fd
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 16, 2022
6693f9c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 17, 2022
0830570
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 18, 2022
4d7149c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 22, 2023
53e3938
👌 IMPROVE: Added test cases for Project Euler Problem 4
omkarnathparida Oct 22, 2023
96224e7
👌 IMPROVE: auto prettier fixes
omkarnathparida Oct 22, 2023
2863fa1
📦 NEW: Project Euler Problem 5 improvement and added test cases
omkarnathparida Sep 28, 2024
718d515
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Sep 28, 2024
31329fc
Merge branch 'master' into project-euler-5
omkarnathparida Sep 28, 2024
96735d2
Updated Documentation in README.md
pomkarnath98 Sep 28, 2024
b58c0a7
👌 IMPROVE: code improve
omkarnathparida Sep 28, 2024
f19f152
Merge branch 'project-euler-5' of https://github.com/pomkarnath98/Jav…
omkarnathparida Sep 28, 2024
5f7d046
🐛 FIX: remove extra code
omkarnathparida Oct 3, 2024
c0bf102
Merge branch 'TheAlgorithms:master' into project-euler-5
pomkarnath98 Oct 5, 2024
a1117ef
👌 IMPROVE: test cases writing imrovements
omkarnathparida Oct 8, 2024
f3afdbb
Merge branch 'project-euler-5' of https://github.com/pomkarnath98/Jav…
omkarnathparida Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
* [ROT13](Ciphers/ROT13.js)
* [VigenereCipher](Ciphers/VigenereCipher.js)
* [XORCipher](Ciphers/XORCipher.js)
* **Compression**
* [RLE](Compression/RLE.js)
* **Conversions**
* [ArbitraryBase](Conversions/ArbitraryBase.js)
* [ArrayBufferToBase64](Conversions/ArrayBufferToBase64.js)
Expand Down Expand Up @@ -285,6 +287,7 @@
* [Problem016](Project-Euler/Problem016.js)
* [Problem017](Project-Euler/Problem017.js)
* [Problem018](Project-Euler/Problem018.js)
* [Problem019](Project-Euler/Problem019.js)
* [Problem020](Project-Euler/Problem020.js)
* [Problem021](Project-Euler/Problem021.js)
* [Problem023](Project-Euler/Problem023.js)
Expand Down
8 changes: 3 additions & 5 deletions Project-Euler/Problem005.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ Smallest multiple
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
*/

export const findSmallestMultiple = () => {
const divisors = [
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
]
let num = 21
export const findSmallestMultiple = (maxDivisor) => {
const divisors = Array.from({ length: maxDivisor }, (_, i) => i + 1)
let num = maxDivisor + 1
let result

while (!result) {
Expand Down
15 changes: 15 additions & 0 deletions Project-Euler/test/Problem005.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { findSmallestMultiple } from '../Problem005.js'

describe.concurrent('Find smallest multiple', () => {
test('if max divisor is 10', () => {
expect(findSmallestMultiple(10)).toBe(2520)
})
test('if max divisor is 15', () => {
expect(findSmallestMultiple(15)).toBe(360360)
})

// Project Euler Condition Check
test('if max divisor is 20', () => {
expect(findSmallestMultiple(20)).toBe(232792560)
})
})