package main
import "fmt"
func main() {
var num int
fmt.Scan(&num)
fmt.Println(getFirstNumber(num))
}
func getFirstNumber(num int) int {
if num < 10 {
return num
} else {
return getFirstNumber(num / 10)
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter