using System;
public class Solution {
public bool solution(int x) {
bool answer = true;
string result = x.ToString();
int sum = 0;
for (int i = 0; i < result.Length; i++)
{
sum += (int)Char.GetNumericValue(result[i]);
}
answer = x % sum == 0 ? true : false;
return answer;
}
}
'프로그래머스 > Lv.1' 카테고리의 다른 글
[프로그래머스 C#] 콜라츠 추측 (0) | 2023.09.11 |
---|---|
[프로그래머스 C#] 정수 제곱근 판별 (0) | 2023.09.03 |
[프로그래머스 C#] 없는 숫자 더하기 (0) | 2023.09.02 |
[프로그래머스 C#] 나누어 떨어지는 숫자 배열 (0) | 2023.08.29 |
[프로그래머스 C#] 수박수박수박수박수박수? (0) | 2023.08.29 |