Remove live code & console.log, leave examples as comments (ProjectEuler, Recursive).

This commit is contained in:
Eric Lavault
2021-10-10 18:18:25 +02:00
parent 9212e6d684
commit 5f45b540b9
17 changed files with 48 additions and 98 deletions

View File

@ -31,10 +31,10 @@ const getCollatzSequenceLength = (num, seqLength) => {
}
}
const findLongestCollatzSequence = () => {
export const findLongestCollatzSequence = (limit = 1_000_000) => {
let startingPointForLargestSequence = 1
let largestSequenceLength = 1
for (let i = 2; i < 1000000; i++) {
for (let i = 2; i < limit; i++) {
const currentSequenceLength = getCollatzSequenceLength(i, 1)
if (currentSequenceLength > largestSequenceLength) {
startingPointForLargestSequence = i
@ -43,5 +43,3 @@ const findLongestCollatzSequence = () => {
}
return startingPointForLargestSequence
}
console.log(findLongestCollatzSequence())