Skip to content

Instantly share code, notes, and snippets.

@egeozcan
Created February 10, 2012 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egeozcan/1788732 to your computer and use it in GitHub Desktop.
Save egeozcan/1788732 to your computer and use it in GitHub Desktop.
Project Euler Problem 3 - JavaScript Solution
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);
@romank604
Copy link

Smooth! Thank you for a beautiful JS solution.

@BENOITHAVETlmj
Copy link

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