손코딩
[프로그래머스] 하샤드수 본문
728x90
728x90
class Solution {
public boolean solution(int x) {
boolean answer = true;
int a = 0;
int y = x;
while(y >= 1){
a += y % 10;
y = y/10;
};
if(x % a != 0){
answer = false;
}
return answer;
}
}
'Java' 카테고리의 다른 글
[프로그래머스] 예산 (0) | 2021.01.28 |
---|---|
[프로그래머스] x만큼 간격이 있는 n개의 숫자 (0) | 2021.01.28 |
[프로그래머스] 콜라츠 추측 (0) | 2021.01.27 |
[프로그래머스] 짝수와 홀수 (0) | 2021.01.27 |
[프로그래머스] 자릿수 더하기 (0) | 2021.01.27 |