Message364749
I don't know... To my mind, if we are going to support working with primes, the minimum API is:
- is_prime(n)
- next_prime(n)
- prev_prime(n)
- factorise(n)
- generate_primes(start=0)
(I trust the names are self-explanatory.)
There are various other interesting prime-related factors which can be built on top of those, but the above five are, in my opinion, a minimal useful set.
Factorising negative numbers is simple: just include a factor of -1 with the prime factors. We would probably want to also support factorising 0 and 1 even though they don't have prime factors. The alternative is to raise an exception, which I expect would be more annoying than useful. |
|
Date |
User |
Action |
Args |
2020-03-21 14:16:10 | steven.daprano | set | recipients:
+ steven.daprano, tim.peters, mark.dickinson, serhiy.storchaka, trrhodes |
2020-03-21 14:16:10 | steven.daprano | set | messageid: <1584800170.56.0.567976580319.issue40028@roundup.psfhosted.org> |
2020-03-21 14:16:10 | steven.daprano | link | issue40028 messages |
2020-03-21 14:16:10 | steven.daprano | create | |
|