제로부터 C# 코딩테스트
프로그래머스 - 저주의 숫자 3
휘게31
2023. 11. 20. 17:35
728x90
주어지는 숫자 n을 숫자 3 또는 3의 배수를 사용하지 않는 마을의 숫자로 변환하는 문제.
.ToString().Contains("")
using System;
public class Solution {
public int solution(int n) {
int answer = 0;
for(int i = 1; i<= n ;i++){
answer++;
while( answer % 3 == 0 || answer.ToString().Contains("3")){
answer++;
}
}
return answer;
}
}
728x90