-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrime_Number.cpp
More file actions
44 lines (40 loc) · 817 Bytes
/
Prime_Number.cpp
File metadata and controls
44 lines (40 loc) · 817 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
static auto _ = [] () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
typedef long long int ll;
typedef vector<int> vint;
int main() {
int n;
cin >> n;
vint PrimeFactor;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
PrimeFactor.push_back(i);
n /= i;
}
}
if (n > 1) {
PrimeFactor.push_back(n);
}
for (auto i : PrimeFactor) {
cout << i << " ";
}
return 0;
}
// int main(){
// int n;cin>>n;
// bool IsPrime = true;
// for(int i=2;i*i<=n;i++){
// if(n % i == 0){
// IsPrime = false;
// break;
// }
// }
// cout<<IsPrime<<endl;
// return 0;
// }