Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Haskell: can someone please help me by completing the functions algorithm? thank

ID: 3672885 • Letter: H

Question

Haskell: can someone please help me by completing the functions algorithm? thanks!

---------------- Functions to implement ---------------------

-- Does a given Chinese Remainder problem have a solution?
-- usage: crtHasSolution as ms = ans
-- assures: ans == True, if
-- (1) the lists as and ms are the same length and nonempty,
-- (2) each element ai of as satisfies ai >= 0,
-- (3) each element mi of ms satisfies mi >= 2, and
-- (4) the elements of ms are pairwise coprime;
-- ans == False, otherwise.

crtHasSolution :: [Integer] -> [Integer] -> Bool
crtHasSolution as ms = undefined


-- Is a particular number a solution to a CR problem?
-- usage: crtIsSolution n as ms = ans
-- assures: ans == True, if crtHasSolution as ms == True and n is a solution
-- ans == False, otherwise

crtIsSolution :: Integer -> [Integer] -> [Integer] -> Bool
crtIsSolution n as ms = undefined


-- Chinese Remaninder Theorem
-- usage: crt as ms = ans
-- assumes: nothing
-- assures: ans == Nothing, if crtHasSolution as ms == False
-- ans == Just n, if n is such that crtIsSolution n as ms == True

crt :: [Integer] -> [Integer] -> Maybe Integer
crt as ms = undefined


-- Modular Exponential, computed via repeated squaring
-- usage: expmod a n m = ans
-- assures: a^n `mod` m == ans

expmod :: Integer -> Integer -> Integer -> Integer
expmod a 0 m = 1
expmod a n m = undefined

Explanation / Answer

Link for Source code and function for CRT.

https://drive.google.com/file/d/0B9P4w87kevGhbGVySDRvMVhrbW8/view?usp=sharing

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote