<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3%2F03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0</id>
	<title>06-数学相关/03-欧拉函数 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3%2F03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;action=history"/>
	<updated>2026-05-20T22:20:33Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=365&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=365&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:11Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:12的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-364:rev-365 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=364&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=364&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:50的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-265:rev-364 --&gt;
&lt;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=265&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=265&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:39Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:25的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-264:rev-265 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=264&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/03-%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0&amp;diff=264&amp;oldid=prev"/>
		<updated>2026-05-20T16:22:29Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
欧拉函数 &amp;lt;math&amp;gt;\varphi(n)&amp;lt;/math&amp;gt; 表示 &amp;lt;math&amp;gt;1\sim n&amp;lt;/math&amp;gt; 中与 &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; 互质的数的个数。&lt;br /&gt;
&lt;br /&gt;
== 求单个欧拉函数 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;O(\sqrt{n})&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\varphi(n)=n\times \prod_{p\mid n}\left(1-\frac{1}{p}\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
long long phi(long long n)&lt;br /&gt;
{&lt;br /&gt;
    long long ans = n;&lt;br /&gt;
    for (long long i = 2; i * i &amp;lt;= n; i++)&lt;br /&gt;
        if (n % i == 0)&lt;br /&gt;
        {&lt;br /&gt;
            ans = ans / i * (i - 1);&lt;br /&gt;
            while (n % i == 0)&lt;br /&gt;
                n /= i;&lt;br /&gt;
        }&lt;br /&gt;
    if (n &amp;gt; 1)&lt;br /&gt;
        ans = ans / n * (n - 1);&lt;br /&gt;
    return ans;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 线性筛求欧拉函数 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;，同时求出 &amp;lt;math&amp;gt;1\sim n&amp;lt;/math&amp;gt; 所有数的欧拉函数值。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const int MAXN = 40000;&lt;br /&gt;
bool p[MAXN + 5];&lt;br /&gt;
int phi[MAXN + 5];&lt;br /&gt;
vector&amp;lt;int&amp;gt; pri;&lt;br /&gt;
&lt;br /&gt;
void get_phi(int n)&lt;br /&gt;
{&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        p[i] = true;&lt;br /&gt;
    p[0] = p[1] = false;&lt;br /&gt;
    phi[1] = 1;&lt;br /&gt;
    for (int i = 2; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        if (p[i])&lt;br /&gt;
        {&lt;br /&gt;
            pri.push_back(i);&lt;br /&gt;
            phi[i] = i - 1;&lt;br /&gt;
        }&lt;br /&gt;
        for (int j = 0; j &amp;lt; pri.size(); j++)&lt;br /&gt;
        {&lt;br /&gt;
            if (1LL * i * pri[j] &amp;gt; n)&lt;br /&gt;
                break;&lt;br /&gt;
            p[i * pri[j]] = false;&lt;br /&gt;
            if (i % pri[j] == 0)&lt;br /&gt;
            {&lt;br /&gt;
                phi[i * pri[j]] = phi[i] * pri[j];&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
                phi[i * pri[j]] = phi[i] * (pri[j] - 1);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 欧拉函数性质 ==&lt;br /&gt;
&lt;br /&gt;
- 若 &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; 是质数，&amp;lt;math&amp;gt;\varphi(p)=p-1&amp;lt;/math&amp;gt;&lt;br /&gt;
- 若 &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; 是质数，&amp;lt;math&amp;gt;\varphi(p^k)=p^k-p^{k-1}&amp;lt;/math&amp;gt;&lt;br /&gt;
- 若 &amp;lt;math&amp;gt;\gcd(a,b)=1&amp;lt;/math&amp;gt;，则 &amp;lt;math&amp;gt;\varphi(ab)=\varphi(a)\times\varphi(b)&amp;lt;/math&amp;gt;（积性函数）&lt;br /&gt;
- &amp;lt;math&amp;gt;\sum_{d\mid n}\varphi(d)=n&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 欧拉定理 ==&lt;br /&gt;
&lt;br /&gt;
若 &amp;lt;math&amp;gt;\gcd(a,m)=1&amp;lt;/math&amp;gt;，则：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a^{\varphi(m)}\equiv 1\pmod m&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
当 &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; 为质数时就是费马小定理。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:数学相关]]&lt;br /&gt;
[[Category:三三文档]]&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>