코드업 1620 자릿수 합
어떤 수 n이 입력되면 n의 각 자릿수의 합이 한 자리가 될때까지 계산하여 출력하시오. 예) 1234567 1234567 → 1+2+3+4+5+6+7 = 28 → 2 + 8 = 10 → 1 + 0 = 1 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String num = sc.next(); String [] snum = null; while(true) { //사이클 돌때마다 i값 초기화 int i = 0; //자릿수가 2개 미만일 시 입력한 값 출력 및 루프탈출 if(num.length() < 2) { System.out.prin..
Comment