Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Midterm Solutions (Coding)
- subsets [] = pp[[
- subsets (x:xs) = subsets xs ++ addToEach x (subsets xs)
- addToEach x [] = []
- addToEach x (xs:xss) = (x:xs) : addToEach x xss
- comb _ 0 = [[]]
- comb [] _ = []
- comb (x:xs) n = addToEach x (comb xs (n-1)) ++ comb xs n
- primeFactors n = pfHelper n 2
- pfHelper n f | n < f = []
- | (mod n f == 0) = f : pfHelper (div n f)
- | otherwise = pfHelper n (f+1)
- checkBase n = noDups (primeFactors n)
- noDups [x] = True
- noDups x:y:xs = (x /= y) && noDups (y:ys)
- idiv2 [] = []
- idiv2 [x] = []
- idiv2 (x:y:xs) = x: idiv2 xs
Add Comment
Please, Sign In to add comment