Created
February 10, 2012 10:50
-
-
Save egeozcan/1788732 to your computer and use it in GitHub Desktop.
Project Euler Problem 3 - JavaScript Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var originalTarget = 600851475143; | |
var target = originalTarget; | |
var i = 2; | |
while(i<target) { | |
while(target%i === 0) { | |
(function(newtarget) { | |
console.log(target + " can be divided by " + i + " which gives us " + newtarget); | |
target = newtarget; | |
})(target / i) | |
} | |
i++; | |
} | |
console.log("it seems like " + target + " is the biggest prime factor for " + originalTarget); |
Hi, thank you, i am just starting in programming and this exercises helps me a lot, i need to understand the structure now ;0,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Smooth! Thank you for a beautiful JS solution.