From b26baef31ed8956098fe3d65bf0636895fb571b4 Mon Sep 17 00:00:00 2001 From: Waddah Date: Sat, 17 Oct 2020 23:11:26 +0300 Subject: [PATCH] remove files to merge from seprate brnches --- Project-Euler/Problem005.js | 22 ---------------------- Project-Euler/Problem006.js | 24 ------------------------ 2 files changed, 46 deletions(-) delete mode 100644 Project-Euler/Problem005.js delete mode 100644 Project-Euler/Problem006.js diff --git a/Project-Euler/Problem005.js b/Project-Euler/Problem005.js deleted file mode 100644 index 0ba30669a..000000000 --- a/Project-Euler/Problem005.js +++ /dev/null @@ -1,22 +0,0 @@ -/* -Smallest multiple - -2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. -What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? -*/ - -const findSmallestMultiple = () => { - const divisors = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2] - let num = 21 - let result - - while (!result) { - const isDivisibleByAll = divisors.every((divisor) => num % divisor === 0) - if (isDivisibleByAll) result = num - else num++ - } - - return result -} - -console.log(findSmallestMultiple()) diff --git a/Project-Euler/Problem006.js b/Project-Euler/Problem006.js deleted file mode 100644 index 181ed6be5..000000000 --- a/Project-Euler/Problem006.js +++ /dev/null @@ -1,24 +0,0 @@ -/* -Sum square difference -The sum of the squares of the first ten natural numbers is 385, - -The square of the sum of the first ten natural numbers is 3025, - -Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 2640. - -Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. -*/ - -const findSumSquareDifference = (elementsCount) => { - const naturalNumbers = Array(elementsCount).fill().map((_, i) => i + 1) - - let sumOfSquares = 0 - naturalNumbers.forEach(number => { sumOfSquares += Math.pow(number, 2) }) - - const sumOfNumbers = naturalNumbers.reduce((prev, current) => { current += prev }, 0) - const squareOfSums = Math.pow(sumOfNumbers, 2) - - return squareOfSums - sumOfSquares -} - -console.log(findSumSquareDifference(20))