Skip to content

Rewrite factorized #6

@neizod

Description

@neizod

factorized is an elegant function (returns list), but most of the time, we didn't need all factors, just 1st of them.

new factor should be class that return factor object, which has this properties:

  • factor(N).__iter__() returns generator that yielded all elem as same as factorized. (so we can do product(factor(N)) == N)
  • factor.(N)items() returns tuple of (prime, power).
  • factor(N).__mul__(M) gives output as same as factor(N*M), just faster because we already know that N*M is not prime.
  • factor(N).__str__() show string repr of the factor in this example form: 2**5 * 3**2 * 7**1 * ...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions