Exemple #1
0
def test_primepi():
    assert primepi(1) == 0
    assert primepi(2) == 1
    assert primepi(5) == 3
    assert primepi(11) == 5
    assert primepi(57) == 16
    assert primepi(296) == 62
    assert primepi(559) == 102
    assert primepi(3000) == 430
    assert primepi(4096) == 564
    assert primepi(9096) == 1128
    assert primepi(25023) == 2763
Exemple #2
0
def test_primepi():
    assert primepi(1) == 0
    assert primepi(2) == 1
    assert primepi(5) == 3
    assert primepi(11) == 5
    assert primepi(57) == 16
    assert primepi(296) == 62
    assert primepi(559) == 102
    assert primepi(3000) == 430
    assert primepi(4096) == 564
    assert primepi(9096) == 1128
    assert primepi(25023) == 2763
    assert primepi(10**8) == 5761455
    assert primepi(253425253) == 13856396
    assert primepi(8769575643) == 401464322
def test_primepi():
    assert primepi(1) == 0
    assert primepi(2) == 1
    assert primepi(5) == 3
    assert primepi(11) == 5
    assert primepi(57) == 16
    assert primepi(296) == 62
    assert primepi(559) == 102
    assert primepi(3000) == 430
    assert primepi(4096) == 564
    assert primepi(9096) == 1128
    assert primepi(25023) == 2763
Exemple #4
0
def test_primepi():
    assert primepi(-1) == 0
    assert primepi(1) == 0
    assert primepi(2) == 1
    assert primepi(Rational(7, 2)) == 2
    assert primepi(3.5) == 2
    assert primepi(5) == 3
    assert primepi(11) == 5
    assert primepi(57) == 16
    assert primepi(296) == 62
    assert primepi(559) == 102
    assert primepi(3000) == 430
    assert primepi(4096) == 564
    assert primepi(9096) == 1128
    assert primepi(25023) == 2763
    assert primepi(10**8) == 5761455
    assert primepi(253425253) == 13856396
    assert primepi(8769575643) == 401464322
    sieve.extend(3000)
    assert primepi(2000) == 303

    n = Symbol('n')
    assert primepi(n).subs(n, 2) == 1

    r = Symbol('r', real=True)
    assert primepi(r).subs(r, 2) == 1

    assert primepi(S.Infinity) is S.Infinity
    assert primepi(S.NegativeInfinity) == 0

    assert limit(primepi(n), n, 100) == 25

    raises(ValueError, lambda: primepi(I))
    raises(ValueError, lambda: primepi(1 + I))
    raises(ValueError, lambda: primepi(zoo))
    raises(ValueError, lambda: primepi(nan))