← Unit 2 · all exercises
Saved in this browser only

The biggest digit

Return the largest digit in a positive number. For 4728 that is 8.

int largestDigit(int n)

Solution.java
Loading editor…
Results

Examples

  • largestDigit(4728) → 8
  • largestDigit(1111) → 1

There are also 4 hidden tests you can't see. Solve the problem, not the examples.