MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / mobiusFunction

Function mobiusFunction

Maths/MobiusFunction.js:23–33  ·  view source on GitHub ↗
(number)

Source from the content-addressed store, hash-verified

21
22import { PrimeFactors } from './PrimeFactors.js'
23export const mobiusFunction = (number) => {
24 const primeFactorsArray = PrimeFactors(number)
25 if (number <= 0) {
26 throw new Error('Number must be greater than zero.')
27 }
28 return primeFactorsArray.length !== new Set(primeFactorsArray).size
29 ? 0
30 : primeFactorsArray.length % 2 === 0
31 ? 1
32 : -1
33}

Callers 1

Calls 1

PrimeFactorsFunction · 0.90

Tested by

no test coverage detected