diff --git a/JS/10.Summation_of_primes/rajkharvar.js b/JS/10.Summation_of_primes/rajkharvar.js new file mode 100644 index 0000000..ea645f7 --- /dev/null +++ b/JS/10.Summation_of_primes/rajkharvar.js @@ -0,0 +1,24 @@ +function summationOfPrimes() { + let num = 2000000; + let result = 0; + + for (let i = 2; i <= num; i++) { + if (isPrime(i)) result += i; + } + + alert(result); +} + +function isPrime(number) { + let result = true; + + for (let i = 2; i <= Math.floor(Math.sqrt(number)); i++) { + if (number % i == 0) { + result = false; + break; + } + } + return result; +} + +summationOfPrimes(); diff --git a/README.md b/README.md index b794d72..05aa752 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Happy Contributing! 😃 | 07 | [10001st prime](https://projecteuler.net/problem=7) | :white_check_mark: | | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | | | | | 08 | [Largest product in a series](https://projecteuler.net/problem=8) | | | | :white_check_mark: | | | | | | | | | | 09 | [Special Pythagorean triplet](https://projecteuler.net/problem=9) | :white_check_mark: | | | :white_check_mark: | | | | | | | | | -| 10 | [Summation of primes](https://projecteuler.net/problem=10) | | | | :white_check_mark: | | | :white_check_mark: | | | | | | +| 10 | [Summation of primes](https://projecteuler.net/problem=10) | | | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | | | | | | | 11 | [Largest product in a grid](https://projecteuler.net/problem=11) | | | | :white_check_mark: | | | :white_check_mark: | | | | | | | 12 | [Highly divisible triangular number](https://projecteuler.net/problem=12) | | | | :white_check_mark: | | | :white_check_mark: | | | | | | | 13 | [Large sum](https://projecteuler.net/problem=13) | :white_check_mark: | | | :white_check_mark: | | | | | | | | | @@ -90,5 +90,3 @@ Happy Contributing! 😃 - We are reluctant to change/modify the already merged P.R. to meet the current Guidelines, as that may modify the contributer's title to that file. - We would appriciate, if all of you could do the necessary modification, hence it won't affect your contribution as per HacktoberFest. - Keep Up the Efforts. - -