数论 欧拉函数 基础题

(板子)数论 欧拉函数

C++ AC代码:
#include
using namespace std;
void ha(int x)
{
int ans=x;
for(int i=2;ii<=x;i++){
if(x%i==0){
ans=ans/i
(i-1);
while(x%i==0) x=x/i;
}
}
if(x>1) ans=ans/x*(x-1);
cout<<ans<<endl;
}
int main(){
int n;
while(scanf("%d",&n)&&n){
ha(n);
}
}

相关文章:

  • 2021-06-27
  • 2021-06-09
  • 2021-09-14
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
相关资源
相似解决方案