Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- def primes(max_n):
- found = [2, 3]
- for candidate in xrange(4, max_n + 1):
- for prime in found:
- if not candidate % prime:
- import pdb; pdb.set_trace()
- break
- else:
- found.append(candidate)
- return found
- class PrimeTest(unittest.TestCase):
- def test_primes(self):
- actual = primes(20)
- self.assertEqual(actual, [2, 3, 5, 7, 11, 13, 17, 19])
- if __name__ == '__main__':
- unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement