simplify code a bit

This commit is contained in:
filifa 2025-06-26 10:55:42 -04:00
parent 8f346d78d6
commit e33113facc
1 changed files with 2 additions and 3 deletions

View File

@ -20,7 +20,7 @@
"Put simply, this means that smaller prime factors will lead to a larger $n/\\phi(n)$. These two facts suggest we should try numbers that are the product of the first several primes, which are called [primorials](https://en.wikipedia.org/wiki/Primorial). Our answer then is the largest primorial less than 1000000:\n",
"$$2 \\times 3 \\times 5 \\times 7 \\times 11 \\times 13 \\times 17 = 510510$$\n",
"\n",
"Alternatively, you can just ask SageMath - its implementation of $\\phi(n)$ is fast enough for this problem. However, you might run into difficulties writing your own implementation that's this fast."
"Alternatively, you can just ask SageMath - its implementation of $\\phi(n)$ is fast enough to brute force this problem. However, you might run into difficulties writing your own implementation that's this fast."
]
},
{
@ -41,8 +41,7 @@
}
],
"source": [
"qs = {n: n/euler_phi(n) for n in range(1, 1000001)}\n",
"max(qs, key=qs.get)"
"max(range(1, 1000001), key=lambda n: n / euler_phi(n))"
]
},
{