We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba22c1c commit 069bf12Copy full SHA for 069bf12
Challenge/SoyeonJang/044.각_자리수의_합/README.md
@@ -0,0 +1,17 @@
1
+# 문제44 : 각 자리수의 합
2
+
3
+**사용자가 입력한 양의 정수의 각 자리수의 합을 구하는 프로그램**을 만들어주세요
4
5
+**예를들어**
6
+18234 = 1+8+2+3+4 이고 정답은 18 입니다.
7
+3849 = 3+8+4+9 이고 정답은 24입니다.
8
9
+```jsx
10
+**입출력**
11
12
+입력 : 18234
13
+출력 : 18
14
15
+입력 : 3849
16
+출력 : 24
17
+```
Challenge/SoyeonJang/044.각_자리수의_합/solve.js
@@ -0,0 +1,29 @@
+/*
18
19
+*/
20
21
+let num = 18234;
22
+let sum = 0;
23
24
+while (num !== 0) {
25
+ sum += num % 10;
26
+ num = Math.floor(num / 10);
27
+}
28
29
+console.log(sum);
0 commit comments