From dccae484b38abb22e6272cdc4779bd90ae8a5b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C5=9F=C4=B1nsu=20Ar=C4=B1c=C4=B1?= Date: Wed, 26 Jan 2022 21:38:18 +0300 Subject: [PATCH] 1281 --- ...1_SubtracttheProductandSumofDigitsofanInteger.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 E_1281_SubtracttheProductandSumofDigitsofanInteger.java diff --git a/E_1281_SubtracttheProductandSumofDigitsofanInteger.java b/E_1281_SubtracttheProductandSumofDigitsofanInteger.java new file mode 100644 index 0000000..d7cec36 --- /dev/null +++ b/E_1281_SubtracttheProductandSumofDigitsofanInteger.java @@ -0,0 +1,11 @@ +public class Solution { + public int subtractProductAndSum(int n) { + int toplam=0,carpim=1; + while(n!=0) { + toplam= (n%10)+toplam; + carpim= (n%10)*carpim; + n/=10; + } + return carpim-toplam; + } +} \ No newline at end of file