当前位置:网站首页>Mathematical knowledge: Euler function - Euler function
Mathematical knowledge: Euler function - Euler function
2022-06-23 07:45:00 【Fight! Sao Nian!】
subject :AcWing 873. Euler function
Given n A positive integer ai, Please find the Euler function of each number .
The definition of Euler function
1∼N China and N The number of Coprime numbers is called Euler function , Write it down as ϕ(N).
If in the basic theorem of arithmetic ,N=p1a1p2a2…pmam, be :
ϕ(N) = N×(p1−1)/p1×(p2−1)/p2×…×(pm−1)/pm
Input format
The first line contains integers n.
Next n That's ok , Each line contains a positive integer ai.
Output format
The output, n That's ok , Each line outputs a positive integer ai The Euler function of .
Data range
1≤n≤100,
1≤ai≤2×109
sample input :
3
3
6
8
sample output :
2
2
4
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int a;
cin>>a;
int res=a;
for(int i=2;i<=a/i;i++)
if(a%i==0)
{
res=res/i*(i-1);
while(a%i==0)a/=i;
}
if(a>1)res=res/a*(a-1);
cout<<res<<endl;
}
return 0;
}
边栏推荐
- 20bn Jester complete dataset Download
- [markdown] markdown tutorial summary
- MySQL系统表介绍
- Console Application
- Product axure9 (English version), prototype design and production pull-down secondary menu
- 快手350014
- Qt工程报错:-1: error: Cannot run compiler ‘clang++‘. Output:mingw32-make.exe
- What is distributed?
- The road to hcip MPLS
- HCIP之路MPLS
猜你喜欢

帆软堆积图显示占比

Nacos adapts to oracle11g- modify the source code of Nacos

《一周的朋友》

在kubernetes中部署kubersphere

Vs problems when connecting to SQL myconn OPen(); cannot execute

某年某月某公司的面试题(1)

链游飞船开发 农民世界链游开发 土地链游开发

传智教育 | 项目发布前如何打tag标签及标签命名规范

Design of temperature detection and alarm system based on 51 single chip microcomputer

MIT CMS.300 Session 12 – IDENTITY CONSTRUCTION 虚拟世界中身份认同的建立 part 2
随机推荐
Console Application
How MySQL converts a date to a number
Solutions to abnormal network connection of Xiaoai speakers
Feelm joined the Carbon Disclosure Project as an initiative of Smallville to deal with climate change emergencies
论文伪代码规范,伪代码在线编辑器,
unity转微信小程序小游戏
How do I install MySQL on my computer?
G++ compilation command use
User mode and kernel mode
2. probability theory - axiom of probability theory
Nacos adapts to oracle11g- modify the source code of Nacos
Here comes the dry goods | PAAS collection to see first ~
在线JSON转CSharp(C#)Class工具
Can you think of a better way to solve the problem of string inversion?
带你玩tiktok就这么简单
Guava Cache 使用小结
Abnormal logic reasoning problem of Huawei software test written test
Qt 使用QDomDocument读取xml文件
在线文本过滤小于指定长度工具
Basic experiment of data statistics and analysis - basic grammar and operation