Skip to content

Instantly share code, notes, and snippets.

@atushi
Created July 12, 2013 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atushi/5983526 to your computer and use it in GitHub Desktop.
Save atushi/5983526 to your computer and use it in GitHub Desktop.
Project Euler . Problem 3 . Largest prime factor : The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
var TARGETNUM = 600851475143;
var t = TARGETNUM;
var i = 2;
var answer = 0;
while (true) {
answer = t;
if ((t%i)==0) t=(t/i);
if (t<=i) break;
i++;
}
console.log(answer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment