프로그래머스 하샤드 수

Algorithm/프로그래머스

[알고리즘] 하샤드 수 Java

class Solution { public boolean solution(int x) { boolean answer = true; int y = x; int sum = 0; while(x > 0) { sum += x % 10; x /= 10; } answer = y % sum == 0 ? true : false; return answer; } }

rw-
'프로그래머스 하샤드 수' 태그의 글 목록