Digit Product Minus Sum

You can work with the digits of a number separately: add them, multiply them, and compare the results. Given an integer n, find the product of all its digits and the sum of all its digits. Return the difference: product minus sum.

Примеры

Ввод
234
Вывод
15
Ввод
4421
Вывод
21
Ввод
1
Вывод
0

Нужно реализовать

def subtract_product_and_sum(n: int) -> int:

Теги

math
PostgreSQLv16

Tu sa zobrazí výsledok spustenia kódu

Visible tests
1
Input
234
Expected15
2
Input
4421
Expected21
3
Input
1
Expected0
4
Input
10
Expected-1
5
Input
99
Expected63
6
Input
0
Expected0
Focus radio
Paused · SomaFM · Fluid