Beakjoon&프로그래머스/Java
[프로그래머스/Java] 자릿수 더하기
현장
2025. 2. 23. 16:01
-Code
public class Solution {
public int solution(int n) {
int answer = 0;
for (String s : ("" + n).split("")) answer += Integer.parseInt(s);
return answer;
}
}