def test_count_primes():
    """Test count_primes function."""
    assert primesieve.count_primes(100) == 25
    assert primesieve.count_primes(10**6) == 78498
    assert primesieve.count_primes(100, 10**6) == 78473
    assert primesieve.count_primes(10**10) == 455052511
    assert primesieve.count_primes(10**9, 10**10) == 404204977
    def test_count_primes(self):
        for testcase1 in ((100, 25), (10**6, 78498), (10**10, 455052511)):
            self.assertEqual(primesieve.count_primes(testcase1[0]),
                             testcase1[1])

        for testcase2 in (((100, 10**6), 78473), ((10**9, 10**10), 404204977)):
            self.assertEqual(
                primesieve.count_primes(testcase2[0][0], testcase2[0][1]),
                testcase2[1])
def _make_pitch_candidates(
    used_primes: typing.Tuple[int, ...] = (3, 5, 7, 11),
    max_exponent: int = 2,
    max_combinations: int = 2,
) -> typing.Tuple[pitches.JustIntonationPitch, ...]:
    elements_per_prime = [[] for _ in used_primes]
    for tonality in (True, False):
        for nth_prime, prime in enumerate(used_primes):
            nth_prime_number = primesieve.count_primes(prime)
            for exponent in range(1, max_exponent + 1):
                exponents = [0 for _ in range(nth_prime_number)]
                exponents[-1] = exponent
                if not tonality:
                    exponents[-1] = -exponents[-1]
                pitch = pitches.JustIntonationPitch(exponents)
                elements_per_prime[nth_prime].append(pitch)

    candidates = [pitches.JustIntonationPitch()]
    for combination in itertools.product(*elements_per_prime):
        for n_pitches in range(1, max_combinations + 1):
            for elements_to_combine in itertools.combinations(
                    combination, n_pitches):
                pitch = functools.reduce(operator.add, elements_to_combine)
                if pitch not in candidates:
                    candidates.append(pitch)
    for candidate in candidates:
        candidate.normalize()
    return tuple(candidates)
示例#4
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import primesieve

LIMIT = 10**10
R = int(LIMIT**(1/2))
counter = 0

for n in range(1, R+1):
    counter += primesieve.count_primes(n, LIMIT//n)

print(LIMIT-counter)
示例#5
0
def test_count_primes():
    assert primesieve.count_primes(100) == 25
    assert primesieve.count_primes(10**6) == 78498
    assert primesieve.count_primes(100, 10**6) == 78473
    assert primesieve.count_primes(10**10) == 455052511
    assert primesieve.count_primes(10**9, 10**10) == 404204977
def test_count_primes():
    assert primesieve.count_primes(100) == 25
    assert primesieve.count_primes(10**6) == 78498
    assert primesieve.count_primes(100, 10**6) == 78473
        self.primePoint = 1
        self.currentFactorialTop = 1

    def sOfP(self, p):
        for i in range(self.currentFactorialTop + 1, p - 4):
            self.primePoint *= i
            self.currentFactorialTop = i

        retVal = 0
        tempFactorial = self.currentFactorialTop
        for i in range(1,6):
            retVal += tempFactorial
            tempFactorial *= (p - 5 + i)
        return retVal % p

print(primesieve.count_primes(10**8))

iterator = primesieve.Iterator()
prime = iterator.next_prime()
prime = iterator.next_prime()
prime = iterator.next_prime()

count = 0
topPoint = 10 ** 8
s = solver()
while prime < topPoint:
    temp = s.sOfP(prime)
    count += temp
    #print (str(prime) + ': ' + str(temp) + ', ' + str(count) + '; ' + str(s.currentFactorialTop) + '! = ' + str(s.primePoint))
    prime = iterator.next_prime()