Created
October 5, 2014 05:07
-
-
Save sordina/0c3d470351d197d038f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import Control.Lens | |
import Data.Bits.Lens | |
import Test.QuickCheck | |
pascal = iterate stepper firstrow | |
where | |
firstrow = [1] | |
stepper r = zipWith (+) ([0] ++ r) (r ++ [0]) | |
binomial n k = pascal !! n !! k | |
prop_lucas n k = n >= 0 | |
==> k >= 0 | |
==> k <= n | |
==> odd (binomial n k) == and (zipWith onBitMatches (toListOf bits k) (toListOf bits n)) | |
onBitMatches True False = False | |
onBitMatches _ _ = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment