Esempio n. 1
0
    def test_reset(self):
        ba = BitArray(10, 1)
        for i in xrange(10):
            self.assertTrue(ba.get_bit(i))

        ba.reset_bit(6)
        self.assertFalse(ba.get_bit(6))
Esempio n. 2
0
def sieve(MAX):
    ba = BitArray(MAX, initialize=1)
    for n in xrange(2, MAX, 2):
        ba.reset_bit(n)

    limit = math.sqrt(MAX)
    limit = math.floor(limit)
    limit = int(limit)

    for n in xrange(3, limit, 2):
        if ba.get_bit(n):
            for i in xrange(n * 2, MAX, n):
                ba.reset_bit(i)

    """