Problem 97

powMod a n m | n < 3 = a^n `mod` m
| otherwise = let (q,r) = divMod n 2
aq = powMod a q m
in aq*aq*a^r `mod` m
main = print $ (powMod 2 7830457 (10^10) * 28433 + 1) `mod` (10^10)