{"size": 596, "ext": "js", "max_stars_repo_path": "src/prime/is.js", "max_stars_repo_name": "zackferrofields/prime-numbers-table", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/prime/is.js", "max_issues_repo_name": "zackferrofields/prime-numbers-table", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prime/is.js", "max_forks_repo_name": "zackferrofields/prime-numbers-table", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.2857142857, "max_line_length": 76, "alphanum_fraction": 0.6241610738}
const {add, all, both, compose, flip, gt, modulo, range} = require('ramda');

// Number → Number → Boolean
const flipdGt = flip(gt);

// Number → Number
const naturalSqrt = i => ~~Math.sqrt(i);

// Number → [Number]
const rangeSqrt = compose(range(2), add(1), naturalSqrt);

// Number → Boolean
const isPrime = i => compose(all(modulo(i)), rangeSqrt)(i);

/**
 * Returns `true` if passed a prime number.
 *
 * @func
 * @sig Number → Boolean
 * @param {Number}
 * @return {Boolean}
 * @example
 *
 *  isPrime(1); //→ false
 *  isPrime(2);  //→ true
 */
module.exports = both(flipdGt(1), isPrime);
