Skip to content

Instantly share code, notes, and snippets.

@egeozcan egeozcan/solution.js
Created Feb 10, 2012

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Sep 10, 2016

Smooth! Thank you for a beautiful JS solution.

@BENOITHAVETlmj

This comment has been minimized.

Copy link

commented Feb 15, 2019

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
You can’t perform that action at this time.