From d4107f24fc89b7052c76fc16d71dd4ffc78d9fe9 Mon Sep 17 00:00:00 2001 From: VisargD Date: Fri, 2 Oct 2020 13:05:35 +0530 Subject: [PATCH] 06 done in Javascript --- JS/06.Sum_Square_Difference/VisargD.js | 23 +++++++++++++++++++++++ README.md | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 JS/06.Sum_Square_Difference/VisargD.js diff --git a/JS/06.Sum_Square_Difference/VisargD.js b/JS/06.Sum_Square_Difference/VisargD.js new file mode 100644 index 0000000..09e3dc1 --- /dev/null +++ b/JS/06.Sum_Square_Difference/VisargD.js @@ -0,0 +1,23 @@ +/** + * Euler 06 in Javascript + */ + +function sum_of_squares() { + var sum = 0; + for (var i = 1; i <= 100; i++) { + sum += (i ** 2); + } + return sum; + } + + function square_of_sum() { + var square; + var sum = 0; + for (var i = 1; i <= 100; i++) { + sum += i; + } + square = sum ** 2; + return square; + } + + console.log(square_of_sum() - sum_of_squares()); \ No newline at end of file diff --git a/README.md b/README.md index b794d72..6f553df 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Happy Contributing! 😃 | 03 | [Largest prime factor](https://projecteuler.net/problem=3) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | | 04 | [Largest palindrome product](https://projecteuler.net/problem=4) | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | :white_check_mark: | | :white_check_mark: | | | | | 05 | [Smallest multiple](https://projecteuler.net/problem=5) | :white_check_mark: | | | :white_check_mark: | | | | | :white_check_mark: | | | | -| 06 | [Sum square difference](https://projecteuler.net/problem=6) | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | | +| 06 | [Sum square difference](https://projecteuler.net/problem=6) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | | | 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: | | | | | | | | |