epicours/Algo/Séminaire/Remediation.md

38 lines
409 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```Ocaml
let rec search n d =
if n = 0 then
false
else if n mod 10 = d then
true
else search (n/10) d
let rec chiffre_maximal n =
  if n < 10 && n > 0 then
    n
  else
    let dernier_chiffre = n mod 10 in
    let reste = n / 10 in
    let max_reste = chiffre_maximal reste in
    if dernier_chiffre > max_reste then
      dernier_chiffre
    else
      max_reste
```