luoheng
12/25/2019 - 1:53 AM

subtractProductAndSum

func subtractProductAndSum(n int) int {
    sum := 0
    mul := 1
    for n != 0 {
        r := n % 10
        n /= 10
        sum += r
        mul *= r
    }
    return mul - sum
    
}