Created
January 21, 2020 16:16
-
-
Save dalcon10028/99b9e7b9a9c7c24074dac063d858b5cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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