当前位置:网站首页>[number theory] Euler function (basic properties, recursive method, formula method, linear sieve method)
[number theory] Euler function (basic properties, recursive method, formula method, linear sieve method)
2022-04-22 07:20:00 【default111】
List of articles
Euler function
- Euler function φ ( n ) \varphi(n) φ(n) : No more than n n n And with the n n n The number of reciprocal positive integers , n ∈ N ∗ n\in N^* n∈N∗
- p p p Prime number ⇔ φ ( p ) = p − 1 \Leftrightarrow\varphi(p)=p-1 ⇔φ(p)=p−1
- p p p Prime number , a ∈ N ∗ ⇒ φ ( p a ) = p a − p a − 1 a\in N^*\Rightarrow \varphi\left(p^{a}\right)=p^{a}-p^{a-1} a∈N∗⇒φ(pa)=pa−pa−1
- prove : And p a p^a pa Not mutually prime only p , 2 p , 3 p , ⋯ , p k − 1 p p,2p,3p,\cdots,p^{k-1}p p,2p,3p,⋯,pk−1p , Sum and subtract in equal proportion
- Arbitrary positive integer n n n The prime power decomposition of n = p 1 a 1 ⋅ p 2 a 2 ⋯ p s a s ⇒ φ ( n ) = n ⋅ ( 1 − 1 p 1 ) ⋅ ( 1 − 1 p 2 ) ⋯ ( 1 − 1 p s ) n=p_{1}^{a_{1}} \cdot p_{2}^{a_2} \cdots p_{s}{ }^{a_{s}}\Rightarrow \varphi(n)=n \cdot\left(1-\frac{1}{p_{1}}\right) \cdot\left(1-\frac{1}{p_{2}}\right) \cdots\left(1-\frac{1}{p_{s}}\right) n=p1a1⋅p2a2⋯psas⇒φ(n)=n⋅(1−p11)⋅(1−p21)⋯(1−ps1)
- prove : It can also be written as φ ( p a ) = p a ( 1 − 1 p ) \varphi\left(p^{a}\right)=p^{a}(1-\frac{1}{p}) φ(pa)=pa(1−p1) , The above formula can be obtained from the fact that Euler function is an integral function .
- inference : When n n n In an odd number of , Yes φ ( 2 n ) = φ ( n ) \varphi(2 n)=\varphi(n) φ(2n)=φ(n)
- n > 2 , n ∈ N ∗ ⇒ φ ( n ) n>2,n\in N^*\Rightarrow \varphi(n) n>2,n∈N∗⇒φ(n) It's even
- n ∈ N ∗ , ∑ d ∣ n φ ( d ) = n n\in N^*,\sum_{d\mid n}\varphi(d)=n n∈N∗,∑d∣nφ(d)=n
- Euler theorem : m m m Is a positive integer , a a a Is an integer ( a , m ) = 1 (a, m)=1 (a,m)=1, that a φ ( m ) ≡ a^{\varphi(m)} \equiv aφ(m)≡ 1 ( m o d m ) 1(\bmod m) 1(modm)
- x m o d p = 0 ⇒ φ ( x p ) = φ ( x ) ⋅ p x\mod p=0\Rightarrow \varphi(xp)=\varphi(x)\cdot p xmodp=0⇒φ(xp)=φ(x)⋅p , Prove the following :
- [ 1 , x ] [1,x] [1,x] China and x x x Non coprime numbers y y y , y + x y+x y+x And x x x Still not coprime , y + c x , c ≤ p y+cx,c\leq p y+cx,c≤p Still with x x x Not mutual , namely [ 1 , x ] [1,x] [1,x] And... In the interval x x x Non coprime numbers are in + c x +cx +cx Still not reciprocal after . The properties of the preceding prime numbers can be proved [ 1 , x ] [1,x] [1,x] China and x x x Coprime numbers are in + c x +cx +cx Still coprime after . So we can get the above conclusion .
notes : The following are from kuangbin The template of
Decomposition prime factor method
int Euler(int n)
{
getFactors(n); // The decomposition quality factor mentioned earlier
int ret = n;
for (int i = 0; i < fatCnt; i++)
ret = ret / factor[i][0] * (factor[i][0] - 1);
return ret;
}
Recurrence method
take φ ( i ) \varphi(i) φ(i) Set first as i i i , hold k i ki ki Original φ \varphi φ Take this i i i Contribution .
In the process , φ \varphi φ No assignment indicates that it is a prime number
int euler[N];
void getEuler()
{
memset(euler, 0, sizeof(euler));
euler[1] = 1;
for (int i = 2; i < N; i++)
if (!euler[i])
for (int j = i; j < N; j += i)
{
if (!euler[j])
euler[j] = j;
euler[j] = euler[j] / i * (i - 1);
}
}
Find a single Euler function
Look for the prime factor , Use formula
int euler(int n)
{
int ans = n;
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
{
ans -= ans / i;
while (n % i == 0)
n /= i;
}
if (n > 1)
ans -= ans / n;
return ans;
}
Linear sieve
bool check[N + 10];
int phi[N + 10];
int prime[N + 10];
int tot; // The number of primes
void phi_and_prime_table(int N)
{
memset(check, false, sizeof(check));
phi[1] = 1;
tot = 0;
for (int i = 2; i <= N; i++)
{
if (!check[i])
{
prime[tot++] = i;
phi[i] = i - 1;
}
for (int j = 0; j < tot; j++)
{
if (i * prime[j] > N)
break;
check[i * prime[j]] = true;
if (i % prime[j] == 0)
{
phi[i * prime[j]] = phi[i] * prime[j]; // Utilization property
break;
}
else
phi[i * prime[j]] = phi[i] * (prime[j] - 1); // Integrability function
}
}
}
版权声明
本文为[default111]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220611440823.html
边栏推荐
- 【Bug小记】keepalive下mounted只执行一次
- SQLSERVER存储过程开发笔记----零碎问题以及关于操作文件的操作
- 把上一次作业第一部分,有参数的类,改成无参数方式呈现,功能不变。
- 机械设计知识点规划
- 【数论】素数(二):素数筛法(埃式筛、欧拉筛、区间筛)
- Robomaster大疆飞手考核
- Choose any novel website, crawl any novel and save it in the form of Notepad.
- 桥接模式下主机ping不通虚拟机
- 自己寻找一个记事本文件,数据素材自找,统计整个文本中,某三个关键字或者语句词条出现的次数。
- 为什么非主键索引的叶子结点存放的数据是主键值
猜你喜欢

Complete a student information management system and systematically practice object-oriented, function, string and other knowledge. Realize the comprehensive application of knowledge. Use classes, fun

jeecg项目部署笔记

模二除运算的上商原则

短路

任选一小说网站,爬取任意一部小说,以记事本的形式保存。
![[jeecg] modify VISER chart color style](/img/24/0a04082592b5f95cdd7aaca78a5dc0.png)
[jeecg] modify VISER chart color style

Review of the sixth edition of introduction to software engineering (notes)

定义一个学生Student类1 获取学生的姓名:get_name() 返回类型:str 2 获取学生的年龄:get_age() 返回类型:int 3 返回3门科目中最高的分数。get_course()

安装和修改uTools及vscode插件安装路径

Flutter环境搭建踩坑过程
随机推荐
SQL server stored procedure development notes - piecemeal problems and operations on operation files
Suppose there is such a relationship between the weight and height of adults: height (CM) - 100 = standard weight (kg). If the difference between a person's weight and its standard weight is between p
【数论】同余(七):快速幂、矩阵快速幂
[number theory] congruence (III): univariate linear congruence equation
【数论】欧拉函数(基本性质、递推法、公式法、线性筛法)
[number theory] congruence (2): inverse element
Help documents on log4net and NLog usage
Scope and lifetime (Mr. Weng Kai)
[number theory] congruence (4): univariate linear congruence equations (elimination of two, Chinese remainder theorem)
完成一个学生信息管理系统,系统练习面向对象、函数、字符串等知识。实现知识的综合应用。 使用类、函数、数据库等来实现
Distributed task scheduling and computing framework: powerjob advanced features - OpenAPI 04
ERROR: [Hsi 55-1545] ,无法正常生成fsbl,Unable to read in MSS file,Failed to closesw system.mss
搭建ES6开发环境,实时编译
MongoDB安装自启动服务
Design a circle class with private member radius representing radius and function get_ Radius () is used to obtain the radius and area () is used to calculate the area of the circle; (2) Define a tabl
[DRC 23-20] Rule violation (REQP-1712) Input clock driver - Unsupported PLLE2_ADV connectivity.
jeecg项目部署笔记
. net learning notes (I) -- introduction, advantages, design ideas, principles and applications of generics
定义一个抽象的Role类有姓名年龄性别爱好等成员变量要求尽可能隐藏所有变量(能够私有就私有)再通过Get()和Set()方法对各变量进行读写,其中龄必须在0到150岁性别必须是男或者女姓名必须是2个字
Noi / 1.5.25: finding special natural numbers