Created
July 12, 2013 10:50
-
-
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 ?
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 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