Skip to content

A different getGcd implementation #17

@Rudxain

Description

@Rudxain

The getGcd function defined at src/utils.ts is dealing with BigInts, so I think it might be a good idea to use Stein's algorithm only if both ints are too large. I'm aware the function is already optimized enough, and adding more code would make minification harder, but this could increase performance.

I already have a hybrid implementation here, but it's too complicated because it also uses Lehmer's algo, which I think is overkill for both libraries, so it shouldn't be included. As some source comments point out, computing the GCD of 2 Mersennes can be done calculating the bitlength, which we can get "for free" if we use an iterative isMersenne helper function, instead of the short expression approach my library uses.

If this is approved, I'll make a pull request with the changes. I'll start writing a small draft to post it here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions