-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11653
More file actions
24 lines (22 loc) · 735 Bytes
/
Copy path11653
File metadata and controls
24 lines (22 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 소인수 분해
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
// 소인수 분해 할 인자들 생각해보기 -> 그냥 prime 알고리즘
for (int i = 2; i <= Math.sqrt(N); i++) {
while (N % i == 0) {
sb.append(i).append('\n');
N /= i;
}
}
if (N != 1) {
sb.append(N);
}
System.out.println(sb);
}
}