mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Remove live code & console.log, leave examples as comments (ProjectEuler, Recursive).
This commit is contained in:
@ -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())
|
||||
|
Reference in New Issue
Block a user