-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5Smallest_multiple.cpp
More file actions
46 lines (43 loc) · 917 Bytes
/
Copy path5Smallest_multiple.cpp
File metadata and controls
46 lines (43 loc) · 917 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
45
46
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
if (n == 1)
{
cout << 1 << endl;
continue;
}
if (n == 2)
{
cout << 2 << endl;
continue;
}
int smallest_miltiple = 2;
for (int i = 3; i <= n; i++)
{
if (smallest_miltiple % i == 0)
{
smallest_miltiple = smallest_miltiple;
}
else
{
for (int j = 2; j <= 40; j++)
{
if (i % j == 0)
{
smallest_miltiple = smallest_miltiple * j;
break;
}
}
}
}
cout << smallest_miltiple << endl;
}
return 0;
}