88 lines
1.6 KiB
Plaintext
88 lines
1.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6cfdb9dc-df35-4ac5-9fa9-da7cae02d2b8",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Euler's product formula\n",
|
|
"\n",
|
|
"$\\phi(n)=n\\prod_{p|n}\\left(1-\\frac{1}{p}\\right)$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"id": "84b0bbc4-48f4-4dc9-a1a9-0cab8f68829a",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"4\n",
|
|
"12\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(euler_phi(12))\n",
|
|
"print(euler_phi(13))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0be1d436-5075-4f2f-96ec-e225179209a7",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Euler's theorem\n",
|
|
"\n",
|
|
"$gcd(a, n)=1$\n",
|
|
"\n",
|
|
"$a^{\\phi(n)}\\equiv1 \\bmod n$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"id": "34b39cb0-1bc0-4f35-8c9f-ff47d575bc9e",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"1\n",
|
|
"1\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(gcd(7,13))\n",
|
|
"print(pow(7,euler_phi(13),13))"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "SageMath 10.6",
|
|
"language": "sage",
|
|
"name": "sagemath-10.6"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.5"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|