Skip to content

Instantly share code, notes, and snippets.

@athas
Created September 8, 2012 16:10
Show Gist options
  • Save athas/3676565 to your computer and use it in GitHub Desktop.
Save athas/3676565 to your computer and use it in GitHub Desktop.
1i3
(* Lidt ændret type... *)
fun relativePrime 0 q = q = 1
| relativePrime p q = relativePrime (q mod p) p;
(* Og en hjælpefunktion der allerede burde være i SML...*)
fun range (from,to) = List.tabulate(to-from+1, fn x => x + from);
(* Så kan den skrives abstrakt. *)
fun nextNotRelativePrime p =
Option.getOpt (List.find (not o relativePrime p) (range(p+1,p*2-1)),
p*2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment