[프로그래머스]하샤드 수

mongs_Develop·2022년 4월 26일
0

Programmers-Level1-Java

목록 보기
5/30
post-thumbnail
  • 문제 & 예시

  • 소스코드

// 하샤드 수
public class test05 {

	public static void main(String[] args) {
		Solution5 sol = new Solution5();
		int x = 12;
		
		System.out.println(sol.solution(x));

	}

}

class Solution5 {
    public boolean solution(int x) {
        boolean answer = true;
        
        int sum = (x / 10) + (x % 10); 
        
        if(x%sum != 0) {
        	answer = false;
        }
        
        return answer;
    }
}
  • consol
profile
개 발 인생

0개의 댓글