prime-factorization

2.0.1 • Public • Published

Prime Factorization Calculator

After you installed the package, place this in your code:

const module = require('prime-factorization');

Factorize a number

There are different ways to factorize (19386 as an example):

const firstMethod = module.Factorize(19386, 'asArray'); //result in array
const secondMethod = module.Factorize(19386, 'asArrayExp'); //exponentiates same numbers
const thirdMethod = module.Factorize(19386, 'asObject'); //shows all calculations

console.log(firstMethod) //returns [2, 3, 3, 3, 359]
console.log(secondMethod) //returns [2, 27, 359]
console.log(thirdMethod) //returns { 'Calculation 0': '1100 ÷ 2', 'Calculation 1': '550 ÷ 2', 'Calculation 2': '275 ÷ 5', 'Calculation 3': '55 ÷ 5', 'Calculation 4': '11 ÷ 11' }

Check if number is Prime

const myVar = module.IsPrime(111) //will return either true or false
console.log(myVar) //returns true

For the web interface: https://helloworld-html.github.io/Prime-Factorization-Calculator/

Please report any bugs or errors, thanks for your contribution!

Package Sidebar

Install

npm i prime-factorization

Weekly Downloads

7

Version

2.0.1

License

ISC

Unpacked Size

2.85 kB

Total Files

3

Last publish

Collaborators

  • helloworld-javascript