You don't need a accumulator to collect your largest digit. But you still need to have the largest digit so far.
So this can be done like this. You can create a local function
max_digit' : int -> int -> int which is the recursive one.
And you call it recursive by remove the rightmost digit and extract the the rightmost and check if it is largest of current largest and the current rightmost. Use that in recursion call.
let max_digit number =
let rec max_digit' number maxsofar =
...
max_digit' (number / 10) (max maxsofar (number mod 10))
in
max_digit' number (number mod 10)
So the inner let is the first call to the local recursive function.
Could even have a local function that return a pair where it divide it. Then you can use a case were you catch (0, maxdigit) as base case. And (number, digit) as the other case.
Something like this.
let max_digit number =
let extract_digit number =
(number/10), (number mod 10)
in
let rec max_digit' number maxsofar =
match extract_digit number with
| (0, cand) -> max cand maxsofar
| (number', cand) -> max_digit' number' (max cand maxsofar)
in
max_digit' number (number mod 10)
This is the usual way of code OCaml. And yes, write the function in your REPL and test it out and build it up part by part, combined. (Notice that F# is MS version of OCaml, but with other library and some syntax changes).