Skip to content

Instantly share code, notes, and snippets.

@Descalon
Created October 2, 2019 14:54
Show Gist options
  • Save Descalon/3c1ca7a7cafc2f569f457cd65fb99c52 to your computer and use it in GitHub Desktop.
Save Descalon/3c1ca7a7cafc2f569f457cd65fb99c52 to your computer and use it in GitHub Desktop.
lab5
module ModularExponentiation where
slowExM :: Integer -> Integer -> Integer -> Integer
slowExM x e m = (x ^ e) `mod` m
exM :: Integer -> Integer -> Integer -> Integer
exM x e m =
let exM' c e' = if e' < e then exM' c' (e'+1) else c'
where c' = (x * c) `mod` m
in exM' 1 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment