(* It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. *) let rec list_of_dec i = if(i=0) then [] else (i mod 10)::(list_of_dec (i/10)) ;; let compare l x = let lx = Sort.list (<) (list_of_dec x) in ( List.length l = List.length lx )&& ( List.for_all2 (=) l lx ) let rec search i = Printf.printf "%d\n" i; if( let l2i = (Sort.list (<) ( list_of_dec (2*i) )) in compare l2i (3*i) && compare l2i (4*i) && compare l2i (5*i) && compare l2i (6*i) ) then Printf.printf "found %d %d %d %d %d %d\n" i (i*2) (i*3) (i*4) (i*5) (i*6) else search (i+1) ;; search 1;;