Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created January 21, 2020 16:16
Show Gist options
  • Select an option

  • Save dalcon10028/99b9e7b9a9c7c24074dac063d858b5cb to your computer and use it in GitHub Desktop.

Select an option

Save dalcon10028/99b9e7b9a9c7c24074dac063d858b5cb to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.close();
int i=0;
int newNum = N;
if(N<10){ // N이 10보다 작다면
newNum = N*10; // 0을 붙여 두 자리 수로 만들고
newNum = newNum%10+newNum/10; // 각 자리의 숫자를 더한다.
}
do{ // 조건문을 바로 만족시켜 버리므로 do-while을 사용했습니다.
newNum = (newNum/10 + newNum%10)%10 + newNum%10*10;
i++;
}while(N!=newNum);
System.out.print(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment