Skip to content

Commit

Permalink
하샤드 수 - level1
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 authored Aug 15, 2022
1 parent d297677 commit d014db9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions programmers/Harshad.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public boolean solution(int x) {
String str = Integer.toString(x);
int sum = 0;

for(int i=0; i<str.length(); i++)
sum += str.charAt(i) - 48;


return (x % sum == 0 ) ? true : false;
}
}

0 comments on commit d014db9

Please sign in to comment.