diff --git a/problem0003.ipynb b/problem0003.ipynb index 9cdc5fa..13d5f3d 100644 --- a/problem0003.ipynb +++ b/problem0003.ipynb @@ -16,7 +16,7 @@ "\n", "In general, as an integer gets larger, [factoring it gets harder](https://en.wikipedia.org/wiki/Integer_factorization). We don't have any efficient algorithm for factoring in general, but somewhat strangely, we don't know for certain that no such algorithm exists.\n", "\n", - "Fortunately for us, this number is not too large for any of these algorithms, or for SageMath (you can even factor it by hand if you have time to kill)." + "Fortunately for us, this number is not too large for any of these algorithms, or for SageMath." ] }, { @@ -52,7 +52,7 @@ "$$x_{i+1} = (x_i^2 - 1) \\bmod{n}$$\n", "Since the number of values this sequence can take on is finite, and each term is determined entirely by the previous term, it must ultimately become periodic, although there may be some initial terms before we reach a term that will repeat (refer to [this image](https://en.wikipedia.org/wiki/File:Pollard_rho_cycle.svg) for a visual aid - the fact this diagram looks like the Greek letter $\\rho$ is where the algorithm gets its name).\n", "\n", - "How many terms will we see before the sequence repeats? If we assume the sequence is random, the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_problem) implies that it will take an average of $O(\\sqrt{n})$ iterations before it repeats. Of course, the sequence is not truly random, but it *is* [pseudorandom](https://en.wikipedia.org/wiki/Pseudorandomness), and experimental results seem to corroborate this analysis despite the somewhat faulty assumption.\n", + "How many terms will we see before the sequence repeats? If we assume the sequence is random, the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_problem) implies that it will take an average of $O(\\sqrt{n})$ iterations before it repeats (this is using [Big O notation](https://en.wikipedia.org/wiki/Big_O_notation)). Of course, the sequence is not truly random, but it *is* [pseudorandom](https://en.wikipedia.org/wiki/Pseudorandomness), and experimental results seem to corroborate this analysis despite the somewhat faulty assumption.\n", "\n", "Now consider the related sequence $\\{x_i \\bmod p\\}$. Obviously, we can't calculate this sequence directly since we don't know the value of $p$, but similarly to $\\{x_i\\}$, this sequence is eventually periodic, with an average of $O(\\sqrt{p})$ iterations before a repetition. In other words, this sequence is expected to repeat earlier than $\\{x_i\\}$.\n", "\n", @@ -89,6 +89,14 @@ " y = x\n", " k *= 2" ] + }, + { + "cell_type": "markdown", + "id": "569b615c", + "metadata": {}, + "source": [ + "Note that this algorithm gives us a factor, but not necessarily a *prime* factor. However, we could just repeatedly apply the algorithm until we only have prime factors left. But how do we know when a factor is prime? We'll need a [primality test](https://en.wikipedia.org/wiki/Primality_test) like the Miller-Rabin algorithm - see [problem 7](https://projecteuler.net/problem=7) for a discussion of that algorithm." + ] } ], "metadata": { diff --git a/problem0004.ipynb b/problem0004.ipynb index 4e02b8f..b50c217 100644 --- a/problem0004.ipynb +++ b/problem0004.ipynb @@ -10,7 +10,7 @@ ">\n", "> Find the largest palindrome made from the product of two 3-digit numbers.\n", "\n", - "Our search space is only $\\binom{900}{2} = 404550$ 3-digit pairs - a lot to check by hand but peanuts to a modern computer. " + "Our search space is only $\\binom{900}{2} = 404550$ 3-digit pairs - a lot to check by hand but peanuts to a modern computer (we're using notation for [combinations](https://en.wikipedia.org/wiki/Combination) if you're unfamiliar)." ] }, { diff --git a/problem0012.ipynb b/problem0012.ipynb index 30fbb19..3240ff3 100644 --- a/problem0012.ipynb +++ b/problem0012.ipynb @@ -21,7 +21,7 @@ ">\n", "> What is the value of the first triangle number to have over five hundred divisors?\n", "\n", - "Yet another problem with a straightforward solution thanks to SageMath's preinstalled functions. We'll also once again apply the closed formula for triangle numbers." + "Yet another problem with a straightforward solution thanks to SageMath's preinstalled functions. We'll also once again apply the closed formula for triangle numbers (see [problem 1](https://projecteuler.net/problem=1))." ] }, {