let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let c = ref 1
let _ = for i = min a b downto 1 do if a mod i = 0 && b mod i = 0 then (if !c >= k then (Printf.printf "%d\n" i; exit 0); incr c) done