You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
290 B

#include<bits/stdc++.h>
using namespace std;
int n;
bool prime(int x) {
int y=sqrt(x);
for(int i=2; i<=y; i++)
if(x%i==0)
return false;
return true;
}
int main() {
scanf("%d",&n);
for(int i=n-1; i>1; i--)
if(prime(i))
if(n%i==0) {
printf("%d\n",i);
return 0;
}
}