OCaml max digit

Can someone, please, tell me how to write a function that prints the max digit of a number?

Is this for an assignment? I’ll give you a hint: if your number is 54 and you integer-divide on 10, you get 5.


Hey, thanks for the answer. Yes, it is for an assignment. x / 10 and x mod 10 I already know, I did play around to see whats going to happen. The problem is that I see I have to put these functions in a specific order in order to get the max digit. I just dont know how to do that. I tried a lot of things, different ways etc, still have no idea how to do it

Just make a recursive function which keeps doing truncated division by 10 on the number, mod 10 to get the last digit, and keep track of the max digit so far.

This has really less to do with OCaml than just thinking of the algorithm.

More hints: with 123, dividing by 10 gives 12, then dividing by 10 gives 1, and then dividing by 10 gives 0 and we know that we went too far.