Git Product home page Git Product logo

Comments (4)

wolfram77 avatar wolfram77 commented on September 2, 2024

I can have primeFactors() return [factor_i, ...], and primeFactorEntries() return [[factor_i, power_i]]. I am assuming small arrays are optimized (for primeFactorEntries()). Any ideas why this might be a good/bad choice?

There could be several optimizations (such as skipping multiples of 3), but for the time being it makes sense to have a working implementation and tests. How do you find proper divisors from the rime factors? I guess it would be based on combinations.

Thanks @skaunov for your sharing.

from extra-bigint.

skaunov avatar skaunov commented on September 2, 2024

from extra-bigint.

wolfram77 avatar wolfram77 commented on September 2, 2024

@skaunov Please see primeFactors() and primeExponentials().

  • primeFactors() returns an array of prime factors (only).
  • primeExponentials() return an array of pairs of prime factors and their exponents.

I use an array of pairs as it can be easily converted to a Map, and allows binary search.

Also added minPrimeFactor() and maxPrimeFactor().

from extra-bigint.

skaunov avatar skaunov commented on September 2, 2024

Looks like an improvement to me! Thank you. =)

from extra-bigint.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.