Skip to content

Commit 896d2d6

Browse files
committed
[이진희] Day18
1 parent a9ac9ec commit 896d2d6

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
3+
1. 아이디어 : n의 각자릿수의 합과 각 자릿수의 곱을 더하고, n으로 나누어떨어지는지 확인
4+
5+
2. 시간복잡도 : O(logN)
6+
7+
3. 자료구조/알고리즘 : 구현
8+
9+
*/
10+
11+
class Solution {
12+
public boolean checkDivisibility(int n) {
13+
int sum = 0;
14+
int mult = 1;
15+
int original = n;
16+
17+
while(n>0) {
18+
sum+=n%10;
19+
mult*=n%10;
20+
21+
n/=10;
22+
}
23+
24+
return original % (sum + mult) == 0;
25+
}
26+
}

0 commit comments

Comments
 (0)