mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 02:05:08 +08:00
Project Euler problems (numbering) : follow naming convention.
This commit is contained in:
18
Project-Euler/Problem003.js
Normal file
18
Project-Euler/Problem003.js
Normal file
@ -0,0 +1,18 @@
|
||||
// https://projecteuler.net/problem=3
|
||||
|
||||
export const largestPrime = (num = 600851475143) => {
|
||||
let newnumm = num
|
||||
let largestFact = 0
|
||||
let counter = 2
|
||||
while (counter * counter <= newnumm) {
|
||||
if (newnumm % counter === 0) {
|
||||
newnumm = newnumm / counter
|
||||
} else {
|
||||
counter++
|
||||
}
|
||||
}
|
||||
if (newnumm > largestFact) {
|
||||
largestFact = newnumm
|
||||
}
|
||||
return largestFact
|
||||
}
|
Reference in New Issue
Block a user