-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.cpp
More file actions
76 lines (54 loc) · 1.01 KB
/
5.cpp
File metadata and controls
76 lines (54 loc) · 1.01 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
long long int t,n,i,j,temp,temp1,flag=1,last;
int *arr;
cin>>t;
while(t--)
{
cin>>n;
arr=new int[n+1];
for(i=1;i<=n;i++)
{
arr[i]=1;
}
last=sqrt(n);
for(i=2;i<=last;i++)
{
if(arr[i]==1)
{
for(j=2;i*j<=n;j++)
arr[i*j]=0;
}
}
temp=1;
for(i=2;i<=n;i++)
{
if(arr[i]==1)
temp*=i;
}
i=1;
while(1)
{
flag=1,temp1=temp*i;
for(j=n;j>=2;j--)
{
if(temp1%j!=0)
{
flag=0;
break;
}
}
if(flag==1)
{
cout<<temp1<<endl;
break;
}
i+=1;
}
free(arr);
}
return 0;
}