# Kotlin Program to find the smallest digit of a number

In this program, You will learn how to find the smallest digit of a number in Kotlin.

```
912342 => 1
972342 => 2
```

## Example: How to find the smallest digit of a number in Kotlin.

```
import java.util.Scanner
fun main(args: Array<String>) {
var n: Int
var r: Int
var sm = 9
var sc = Scanner(System.`in`)
print("Enter a number:")
n = sc.nextInt()
while (n > 0) {
r = n % 10
if (sm > r) {
sm = r
}
n /= 10
}
println("Smallest digit:$sm")
}
```

#### Output:

```
Enter a number:34245
Smallest digit:2
```