let select_size n = let rec powerset = function | [] -> [[]] | x :: xs -> let ps = powerset xs in List.concat [ps; List.map (fun ss -> x :: ss) ps] in let start = powerset [3; 11; 19] |> List.map (fun l -> (l, List.fold_left ( * ) 1 l)) in let rec multiply_by_two (n : int) (target : int) (pow_two : int) = if n >= target then pow_two else multiply_by_two (2 * n) target (2 * pow_two) in List.map (fun (l, e) -> multiply_by_two e n 1 :: l) start |> List.map (fun l -> (l, List.fold_left ( * ) 1 l)) |> fun l -> List.fold_left (fun (l, prod) ((_, acc) as a) -> if prod < acc then (l, prod) else a) (List.hd l) l