[프로그래머스/JAVA]자릿수 더하기

gov's avatar
Dec 09, 2024
[프로그래머스/JAVA]자릿수 더하기
Contents
문제풀이

문제

notion image

풀이

class Solution { public int solution(int n) { int answer = 0; while(n>0){ answer += n%10; n /=10; } return answer; } }
 
Share article

goho