Created
February 6, 2015 22:18
-
-
Save nagat01/01bd8ff25cc469775b45 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <div>problem5 (10) = <p id="a10"></p></div> | |
| <div>problem5 (20) = <p id="a20"></p></div> | |
| <script> | |
| function problem5 (x) { | |
| var primes = []; | |
| for(i = 2; i < x; i++) { | |
| var isPrime = true; | |
| for(j = 0; j < primes.length; j++) { | |
| if(i % primes[j] == 0) | |
| isPrime = false; | |
| } | |
| if(isPrime) { | |
| primes.push(i); } | |
| } | |
| var result = 1; | |
| for(i = 0; i < primes.length; i++) { | |
| var p = primes[i]; | |
| result *= Math.pow(p, Math.floor(Math.log(x) /Math.log(p))); | |
| } | |
| return result; | |
| } | |
| document.getElementById("a10").innerHTML = problem5(10); | |
| document.getElementById("a20").innerHTML = problem5(20); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment