Last active
November 14, 2018 20:23
-
-
Save tuvo1106/d6b572b3f6f6500dcdbf07509a18a840 to your computer and use it in GitHub Desktop.
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
const getCleanerResults = (a,b) => { | |
return checkPrime(add101(multiply5or10(subtract(sum(square(a), double(b)), a)))) | |
} | |
const square = x => x**2 | |
const double = x => x * 2 | |
const sum = (a,b) => a + b | |
const subtract = (a,b) => a - b * 2 | |
const multiply5or10 = x => (x % 2 === 0) ? x * 5 : x * 10 | |
const add101 = x => x + 101 | |
const checkPrime = x => isPrime(x) ? 1 : x | |
const isPrime = num => { | |
for (var i = 2; i < parseInt(num/2); i++) { | |
if (num % i === 0) return false; | |
} | |
return num >= 1; | |
} | |
console.log(getCleanerResults(5, 10)) // 451 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment