Skip to main content

New answers tagged

1 vote

Primality test in Python

A commentary on the style of smallestr and control flow. ...
Chris's user avatar
  • 4,594
3 votes

Prime factorization for integers with up to 9-digit long prime factors

I would look up the pollard-rho algorithm. It doesn’t involve any higher mathematics, so you can implement it yourself. If a number n has a prime factor p, that prime factor can be found in about sqrt(...
gnasher729's user avatar
  • 2,970
7 votes

Find the smallest semiprime satisfying a bunch of conditions

To do this a lot faster: You want to know whether say nine numbers are all primes. The obvious way of checking this is to test if the first number is prime, if it is prime then check the second number ...
gnasher729's user avatar
  • 2,970
5 votes

Find the smallest semiprime satisfying a bunch of conditions

repr repr_a = str(a) I found repr_a a confusing name for this, given that we didn't call ...
J_H's user avatar
  • 42.2k
7 votes

Find the smallest semiprime satisfying a bunch of conditions

As you only use isprime and factorint from sympy it would clean up your code to just import ...
Chris's user avatar
  • 4,594
7 votes

Find the smallest semiprime satisfying a bunch of conditions

any other feedback is welcome too Here are some general coding style recommendations. Documentation The PEP 8 style guide recommends adding a docstring at the top of the code to describe its purpose. ...
toolic's user avatar
  • 15.8k

Top 50 recent answers are included