Beispiel #1
0
def test_prime():
    assert ntheory.prime(1) == 2
    assert ntheory.prime(27) == 103
    with pytest.raises(ValueError):
        ntheory.prime(0)
    with pytest.raises(ValueError):
        ntheory.prime(-1)
Beispiel #2
0
 def test_prime(self):
     self.assertEqual(prime(1), 2)
     self.assertEqual(prime(27), 103)
     self.assertRaises(ValueError, prime, 0)
     self.assertRaises(ValueError, prime, -1)
Beispiel #3
0
 def _gen_primes(self):
     primecnt = 2 + int(1.5 * self._difficulty)
     prime_ind = [1] + random.sample(range(2, int(1.5 * primecnt)),
                                     primecnt - 1)
     primes = [ntheory.prime(i) for i in prime_ind]
     self._numgen = NumPrimeGenerator(primes)
Beispiel #4
0
 def _gen_primes(self):
     primecnt = 2 + int(1.5 * self._difficulty)
     prime_ind = [1] + random.sample(range(2, int(1.5 * primecnt)),
                                     primecnt - 1)
     primes = [ntheory.prime(i) for i in prime_ind]
     self._numgen = NumPrimeGenerator(primes)