Skip to content

Instantly share code, notes, and snippets.

@tuvo1106
Last active November 14, 2018 20:23
Show Gist options
  • Save tuvo1106/d6b572b3f6f6500dcdbf07509a18a840 to your computer and use it in GitHub Desktop.
Save tuvo1106/d6b572b3f6f6500dcdbf07509a18a840 to your computer and use it in GitHub Desktop.
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