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

업데이트:

📚 자릿수 더하기

링크📎 : https://programmers.co.kr/learn/courses/30/lessons/12931

난이도 ⭐️

📖 문제

이미지

📝 내 풀이

import java.util.*;

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

끝-!

댓글남기기