Is Even
by Isai Damier

#======================================================================
# Author: Isai Damier
# Title: isEven
# Project: geekviewpoint
# Package: algorithms
#
# Statement:
#   Indicate whether the given integer is even.
#
# Sample Input: 28
# Sample Output: true
#
# Technical Details: The lowest bit of an even number is 0.
#    0 = 0; 2 = 10; 4 = 100; 6 = 110; 8 = 1000; etc.
#    Therefore, x AND 1 should be 0 for all even numbers.
#====================================================================== 
 def isEven( x ):
  return 0 == ( x & 1 )
import unittest
from algorithms import bitwise as bits

class Test( unittest.TestCase ):

    def testIsEven( self ):
      for i in range( 0, 10000, 2 ):
        self.assertTrue( bits.isEven( i ) )

      for i in range( 1, 10000, 2 ):
        self.assertFalse( bits.isEven( i ) )