<문제 설명>
정수 int a가 주어집니다.
1이상 int a이하의 정수 중 숫자에 13이 들어가는 숫자의 개수를 리턴하세요.
<참고 / 제약 사항>
a는 1이상, 10,000이하 입니다.
테스트 케이스
(1)
int a = 13
리턴(정답): 1
1이상 13이하의 정수중 13이 들어가는 숫자는 13이 유일 합니다.
(2)
int a = 200
리턴(정답): 12
<내가 제출한 코드>
public static int solution(int a){
int quotient = 0, remainder = 0, result = 0;
int tmpRemainder;
for(int i=1; i<=a; i++) {
quotient = i;
tmpRemainder = 0;
while(quotient > 0) {
remainder = quotient%10;
quotient = quotient/10;
if (remainder == 1 && tmpRemainder == 3) {
result++;
break;
}
tmpRemainder = remainder;
}
}
return result;
}