'commit'
This commit is contained in:
20
C++课程/第十六课循环结构程序设计实例2/p175_3_2.cpp
Normal file
20
C++课程/第十六课循环结构程序设计实例2/p175_3_2.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user