欧拉函数及相关定理
欧拉函数
定义
性质
为积性函数,即- 根据定义可知,
- 根据定义可知,
- 由第一分解定理,设
,
欧拉定理
若
当
扩展欧拉定理
一些模板
线性筛欧拉函数
int ss[N],cnt,vs[N],fi[N];
il void init(int n){
fi[1]=1;
for(ri int i=2;i<=n;++i){
if(!vs[i]) ss[++cnt]=i,fi[i]=i-1;
for(ri int j=1;j<=cnt&&ss[j]*i<=n;++j){
vs[i*ss[j]]=1;
if(i%ss[j]) fi[i*ss[j]]=fi[i]*fi[ss[j]];
else{fi[i*ss[j]]=fi[i]*ss[j];break;}
}
}
return;
}
求一个数的欧拉函数
il int fi(int n){
int as=n,res=n;
for(ri int i=2;i*i<=res;++i){
if(res%i==0){
while(res%i==0) res/=i;
as=as/res*(res-1);
}
}
if(res>1) as=as/res*(res-1);
return as;
}
资料
练习题
I went to the woods because I wanted to live deliberately, I wanted to live deep and suck out all the marrow of life, and not when I had come to die, discover that I had not live.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!