prime-factorization
v2.0.1
Published
This calculator allows you to calculate prime factor decomposition of a positive integer and detects if the number is prime
Downloads
6
Maintainers
Readme
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!