A collection of functions useful for solving Project Euler problems
npm install oilerjs
var oiler = require('oilerjs');
var primes = oiler.getPrimeFactors(1023);
console.log(primes); // [ 3, 11, 31 ]
var even = oiler.isEven(1023);
console.log(even); // false
var goc = oiler.isGoldbachsOtherConjecture(1023);
console.log(goc); // true
var pandigital = oiler.isPandigital(1023456789);
console.log(pandigital); // true
var pentagonal = oiler.isPentagonal(477);
console.log(pentagonal); // true
var permuation = oiler.isPermutation(1234, 3241);
console.log(permuation); // true
var prime = oiler.isPrime(91);
console.log(prime); // false
- Constructor
Get the prime factors of 'n'. Shout-out: http://www.coderenaissance.com/2011/06/finding-prime-factors-in-javascript.html
-
Parameters:
n
— -
Returns:
*|Array
—
Is 'n' a prime number? Embarrassingly simple.
-
Parameters:
n
— -
Returns:
boolean
—
Goldbach's other conjecture It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. (It turns out that the conjecture was false.)
-
Parameters:
n
— -
Returns:
boolean
—
Is 'n' a pandigital number?
-
Parameters:
n
— -
Returns:
boolean
—
Is 'n' a pentagonal number? I don't know where I found this formula.
-
Parameters:
n
— -
Returns:
boolean
—
Are n and m permutations of each other? Ugly, but works. Seems like there's a more elegant solution.
-
Parameters:
-
n
— -
m
—
-
-
Returns:
boolean
—
Is 'n' a prime number? Shout-out: http://en.wikipedia.org/wiki/Primality_test
-
Parameters:
n
— -
Returns:
boolean
—
The MIT License (MIT)
Copyright (c) 2015 Will Munslow
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.