Caml light and finding the prime factors I wrote the following Caml light code to find prime factors of a number (part of an early Project Euler question).


  Largest prime factor
  
  The prime factors of 13195 are 5, 7, 13 and 29.
  
  What is the largest prime factor of the number 600851475143?


let rec find_factors target check =
if (check &gt; (int_of_float (sqrt (float_of_int target)))) then [] else
        (find_factors target (check+1))@if target mod check == 0 then 
[ check; (target/check)] else[] ;;

let display n =
print_int n;print_newline();;

do_list display (find_factors 10 1);
print_newline();;


I'm very new to functional programming and I suspect I'm all over the place - if anyone would like to give me some tips that would be ideal. :)
I guess that I should not be giving you an answer, but guide you. So, one general remark that I have: stylistically, it would be preferable to see you start with

let largest_factor n =
    let rec aux_factor d n =
        ...
    in 
        # some expression involving to aux_factor 


The idea is that your solution function should be an expression of your problem and nothing else, so largest_factor number, not largest_factor number what_is_that.

Note that I am talking OCaml here, not sure if the pseudosample I wrote is cromulent Caml Light.