
    
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
            
{"version":"https:\/\/jsonfeed.org\/version\/1","title":"mathspp.com feed","home_page_url":"https:\/\/mathspp.com\/blog\/tags\/number-theory","feed_url":"https:\/\/mathspp.com\/blog\/tags\/number-theory.json","description":"Stay up-to-date with the articles on mathematics and programming that get published to mathspp.com.","author":{"name":"Rodrigo Gir\u00e3o Serr\u00e3o"},"items":[{"title":"Problem #063 \u2013 arbitrarily many primes in arbitrarily big intervals","date_published":"2023-01-29T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/arbitrarily-many-primes-in-arbitrarily-big-intervals","url":"https:\/\/mathspp.com\/blog\/problems\/arbitrarily-many-primes-in-arbitrarily-big-intervals","content_html":"<p>Can you prove that there are arbitrarily many primes in arbitrarily big intervals?<\/p>\n\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The problem statement asks you to prove that for <em>any<\/em> positive integer number <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> you can think of,\nthere will be a certain lower bound <span class=\"mathjax mathjax--inline\">\\(n_0\\)<\/span> (that depends on <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span>) such that for <em>any<\/em> integer <span class=\"mathjax mathjax--inline\">\\(n \\geq n_0\\)<\/span>,\n<em>there is<\/em> an interval of length <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> that contains <em>exactly<\/em> <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> primes.\n(When we talk about the length of the interval, we are talking about how many integers it contains.)<\/p>\n<p>If the statement confused you a bit, that is ok.\nLet me rephrase it.<\/p>\n<p>You and I will play a game.\nI will think of a positive integer <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span>.\nNow, your job is to come up with another positive integer <span class=\"mathjax mathjax--inline\">\\(n_0\\)<\/span> such that,\nif I pick a number <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> greater than <span class=\"mathjax mathjax--inline\">\\(n_0\\)<\/span>,\nyou can always find an interval of size <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> that contains <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> primes.<\/p>\n<p>For example, if I thought of <span class=\"mathjax mathjax--inline\">\\(k = 5\\)<\/span>, you <em>could not<\/em> pick <span class=\"mathjax mathjax--inline\">\\(n_0 = 4\\)<\/span>.\nWhy not?\nBecause if I pick <span class=\"mathjax mathjax--inline\">\\(n = 4\\)<\/span>, there is <em>no<\/em> interval of length <span class=\"mathjax mathjax--inline\">\\(4\\)<\/span> that contains <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> prime numbers...\nEspecially because an interval of length <span class=\"mathjax mathjax--inline\">\\(4\\)<\/span> contains only <span class=\"mathjax mathjax--inline\">\\(4\\)<\/span> integers!<\/p>\n<p>This problem was posed to me by my mathematician cousin and I confess that worried me a bit.\nFunnily enough, the problem has a surprisingly simple solution.\n(I am not saying you will get there easily.\nI am just saying that once you do, you will realise the solution was not very complicated.)<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought!<\/p>\n<\/div>\n<p><strong>Remember<\/strong>:<\/p>\n<ul><li>there are infinitely many primes; however<\/li>\n<li>they become scarcer and scarcer the further you go down the number line.<\/li>\n<\/ul><h2 id=\"solvers\">Solvers<a href=\"#solvers\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Congratulations &#127881; to everyone who managed to solve this problem:\nCongratulations to you if you managed to solve this problem correctly!\nIf you did, feel free to<\/p>\n<ul><li>Rodrigo G. S., Portugal &#127477;&#127481;  (&lt;- example);<\/li>\n<\/ul><p>If <em>you<\/em> managed to solve this problem, you can <a href=\"https:\/\/github.com\/mathspp\/mathspp\/edit\/master\/pages\/02.blog\/02.problems\/p063-arbitrarily-many-primes-in-arbitrarily-big-intervals\/item.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">add your name to the list<\/a>!\nYou can also <a href=\"mailto:rodrigo@mathspp.com?subject=Solution%20to%20Problem%20#063%20%E2%80%93%20arbitrarily%20many%20primes%20in%20arbitrarily%20big%20intervals\" class=\"mailto\">email me<\/a> your solution and we can discuss it.<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>A thing I like about this problem is that not only can you prove that interesting statement about the prime numbers, but you can also determine exactly what the lower bound <span class=\"mathjax mathjax--inline\">\\(n_0\\)<\/span> is.<\/p>\n<p>Let us say that <span class=\"mathjax mathjax--inline\">\\(p_k\\)<\/span> is the <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span>-th prime.\nThen, if we set <span class=\"mathjax mathjax--inline\">\\(n_0 = p_k\\)<\/span>, we are good to go.\nLet me show you why.<\/p>\n<p>Suppose that <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> is any integer <span class=\"mathjax mathjax--inline\">\\(n \\geq n_0\\)<\/span>.\nThen, the interval <span class=\"mathjax mathjax--inline\">\\([1, n]\\)<\/span> contains <span class=\"mathjax mathjax--inline\">\\(p_k\\)<\/span> in it.\nWhy?\nBecause <span class=\"mathjax mathjax--inline\">\\(p_k = n_0\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(n \\geq n_0\\)<\/span>.<\/p>\n<p>So, the interval <span class=\"mathjax mathjax--inline\">\\([1, n]\\)<\/span> contains <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> <em>or more<\/em> prime numbers.\nIf it contains <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> prime numbers, we just found our interval of length <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> that contains exactly <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> primes.\nIf it contains more than <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> primes, we must do something about it.<\/p>\n<p>If the interval <span class=\"mathjax mathjax--inline\">\\([1, n]\\)<\/span> contains more than <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> prime numbers, then we start sliding the interval to the right, like so:...<\/p>","summary":"Can you prove that there are arbitrarily many primes in arbitrarily big intervals? In this mathematical problem, which is just a logic challenge, the solution is surprisingly uncomplicated.","date_modified":"2025-07-23T16:49:02+02:00","tags":["logic","mathematics","number theory","primes"],"image":"\/user\/pages\/02.blog\/03.problems\/p063-arbitrarily-many-primes-in-arbitrarily-big-intervals\/thumbnail.webp"},{"title":"Problem #023 - guess the polynomial","date_published":"2020-11-15T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/guess-the-polynomial","url":"https:\/\/mathspp.com\/blog\/problems\/guess-the-polynomial","content_html":"<p>In this problem you have to devise a strategy to beat the computer in a \"guess the polynomial\" game.<\/p>\n\n<script>\n    var max_degree = 3;\n    var max_coef = 3;\n    var poly_times = 0;\n    var evaluated_at = [];\n\n    \/\/ Generate a random integer between a and b, inclusive.\n    randint = function(a, b) {\n        return Math.floor(Math.random()*(1+b-a)) + a;\n    }\n\n    reset_poly = function() {\n        poly_times = 0;\n        evaluated_at = [];\n        document.getElementById(\"polyHint\").innerHTML = \"\";\n        document.getElementById(\"polyTimes\").innerHTML = 0;\n        document.getElementById(\"polyResult\").innerHTML = \"\";\n        reset_test_coefs();\n        set_disables(guessing = true);\n    }\n\n    \/* set the disabled status of inputs and buttons, depending on whether\n     * the user is currently guessing the poly or not. *\/\n    set_disables = function(guessing) {\n        document.getElementById(\"newPolyBtn\").disabled = guessing;\n        document.getElementById(\"verifyPolyBtn\").disabled = !guessing;\n        document.getElementById(\"giveUpPolyBtn\").disabled = !guessing;\n        set_disabled_test_coefs(disabled = !guessing);\n    }\n\n    reset_test_coefs = function() {\n        for (var i = 0; i <= max_degree; ++i) {\n            document.getElementById(`c${i}`).value = 0;\n        }\n    }\n\n    set_disabled_test_coefs = function(disabled) {\n        for (var i = 0; i <= max_degree; ++i) {\n            document.getElementById(`c${i}`).disabled = disabled;\n        }\n    }\n\n    var poly = new Array(max_degree + 1);\n    generate_poly = function() {\n        for (var i = 0; i <= max_degree; ++i) {\n            poly[i] = randint(0, max_coef);\n        }\n        reset_poly();\n    }\n\n    evaluate_poly = function() {\n        var a = parseInt(document.getElementById(\"polyAt\").value);\n        var value = 0;\n        for (var i = 0; i <= max_degree; ++i) {\n            value += poly[i]*a**i;\n        }\n        document.getElementById(\"polyHint\").innerHTML = `p(${a}) = ${value}`;\n        if (-1 === evaluated_at.indexOf(a)) {\n            evaluated_at.push(a);\n            ++poly_times;\n            document.getElementById(\"polyTimes\").innerHTML = poly_times;\n        }\n    }\n\n    verify_poly = function() {\n        var right = true;\n        for (var i = 0; i <= max_degree; ++i) {\n            right &= document.getElementById(`c${i}`).value === `${poly[i]}`;\n        }\n        if (right) {\n            document.getElementById(\"polyResult\").innerHTML = \"Correct!\";\n            set_disables(guessing = false);\n        } else {\n            document.getElementById(\"polyResult\").innerHTML = \"Wrong!\";\n        }\n    }\n\n    give_up_poly = function() {\n        set_disables(guessing = false);\n        polyResult = `The polynomial was p(n) = ${poly[0]}`\n        for (var i = 1; i<= max_degree; ++i) {\n            polyResult += ` + ${poly[i]}n^${i}`;\n        }\n        document.getElementById(\"polyResult\").innerHTML = polyResult;\n    }\n\n    window.onload = generate_poly;\n<\/script><figure class=\"image-caption\"><img title=\"Photo by Emily Morter on Unsplash\" alt=\"A question mark in a neon light\" src=\"\/images\/6\/e\/e\/9\/7\/6ee97fa1f35461424a54a2d0112230b1a0cc2f18-thumbnail.jpg\"><figcaption class=\"\">Photo by Emily Morter on Unsplash<\/figcaption><\/figure><h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>I want you to play a little game with the computer.\nThe computer is going to think of a polynomial with non-negative, integer coefficients.\nLet's say <span class=\"mathjax mathjax--inline\">\\(p(n)\\)<\/span> is the secret polynomial the computer is thinking of.<\/p>\n<p>I want you to find out what <span class=\"mathjax mathjax--inline\">\\(p(n)\\)<\/span> is, and the only thing you can do is to ask for hints in the form of values of <span class=\"mathjax mathjax--inline\">\\(p(n)\\)<\/span> for <span class=\"mathjax mathjax--inline\">\\(n \\geq 0\\)<\/span> integer.\nFor example, you can ask what <span class=\"mathjax mathjax--inline\">\\(p(0)\\)<\/span> or <span class=\"mathjax mathjax--inline\">\\(p(49)\\)<\/span> is, but you can't ask for the value of <span class=\"mathjax mathjax--inline\">\\(p(-1)\\)<\/span> or <span class=\"mathjax mathjax--inline\">\\(p(0.5)\\)<\/span>.\nYou have to come up with the best strategy possible, that allows you to determine <span class=\"mathjax mathjax--inline\">\\(p(n)\\)<\/span> with the least number of hints possible.<\/p>\n<p>You can test your strategy with the computer below.\nThe computer will only think of polynomials with degree at most <span class=\"mathjax mathjax--inline\">\\(3\\)<\/span>\nand the coefficients will be at most <span class=\"mathjax mathjax--inline\">\\(3\\)<\/span> as well, but that is just to make testing your strategy easier.\nThe strategy should work for higher degrees and larger coefficients.<\/p>\n<p>With the restrictions for the computer test, we have<\/p>\n<p class=\"mathjax mathjax--block\">\\[\np(n) = c_0 + c_1n + c_2n^2 + c_3n^3, 0 \\leq...<\/p>","summary":"In this problem you have to beat the computer in a guessing game.","date_modified":"2025-07-23T16:49:02+02:00","tags":["mathematics","polynomials","number theory","game"],"image":"\/user\/pages\/02.blog\/03.problems\/p023-guess-the-polynomial\/thumbnail.jpg"},{"title":"Twitter proof: consecutive integers are coprime","date_published":"2020-11-14T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/consecutive-integers-are-coprime","url":"https:\/\/mathspp.com\/blog\/consecutive-integers-are-coprime","content_html":"<p>Let's prove that if <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> is an integer, then <span class=\"mathjax mathjax--inline\">\\(\\gcd(k, k+1) = 1\\)<\/span>. That is, any two consecutive integers are coprime.<\/p>\n\n<script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<p><img alt=\"Two consecutive integers are coprime\" src=\"\/images\/7\/b\/2\/3\/f\/7b23f660509f21b995daee842a08888b995cb794-consecutive-coprime.webp\"><\/p>\n<h2 id=\"twitter-proof\">Twitter proof<a href=\"#twitter-proof\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<blockquote class=\"twitter-tweet\">\n<p lang=\"en\" dir=\"ltr\">Twitter proof:<br>Let k be an integer and let d be the greatest common divisor of k and k+1. We have that (k+1)\/d=k\/d+1\/d and both (k+1)\/d and k\/d are integers, so 1\/d must be an integer and we can only have d=1.<a href=\"https:\/\/t.co\/pItsAnueib\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">https:\/\/t.co\/pItsAnueib<\/a><\/p>\u2014 Mathspp (@mathsppblog) <a href=\"https:\/\/twitter.com\/mathsppblog\/status\/1327660984266338321?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">November 14, 2020<\/a>\n<\/blockquote>\n<p>Do you have an idea for a twitter proof? Let me know in the comments below!<\/p>","summary":"In this twitter proof I show that two consecutive integers have to be coprime.","date_modified":"2025-07-23T16:49:02+02:00","tags":["mathematics","number theory","primes"],"image":"\/user\/pages\/02.blog\/consecutive-integers-are-coprime\/consecutive-coprime.webp"},{"title":"Problem #022 - coprimes in the crowd","date_published":"2020-11-01T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/coprimes-in-the-crowd","url":"https:\/\/mathspp.com\/blog\/problems\/coprimes-in-the-crowd","content_html":"<p>This simple problem is an example of a very interesting phenomenon: if you have a large enough \"universe\" to consider, even randomly picked parts exhibit structured properties.<\/p>\n\n<p><img alt=\"A crowd of people, photo by Rob Curran on Unsplash\" src=\"\/images\/4\/a\/6\/6\/e\/4a66e48b9af65eb2a0b7e9bd9aa34ba62f0bd045-crowd.jpg\"><\/p>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Let <span class=\"mathjax mathjax--inline\">\\(n \\geq 2\\)<\/span> be an integer. Then, consider the integers<\/p>\n<p class=\"mathjax mathjax--block\">\\[\n\\{3, 4, \\cdots, 2n-1, 2n\\}\\ .\\]<\/p>\n<p>Show that, if you pick <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> from those, you always have two numbers that will share no divisors whatsoever.<\/p>\n<p>In other words, show that there's two of those <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> numbers that are coprime.<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought...<\/p>\n<\/div>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The solution is a simple application of the pigeonhole principle.<\/p>\n<div class=\"notices blue\">\n<p>The <em>pigeonhole principle<\/em> says that, if you have <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> pigeons and <span class=\"mathjax mathjax--inline\">\\(n &lt; k\\)<\/span> holes, then if you put all pigeons in the holes there will be at least one hole with more than one pigeon.<\/p>\n<\/div>\n<p>For some <span class=\"mathjax mathjax--inline\">\\(n \\geq 2\\)<\/span>, consider the following <span class=\"mathjax mathjax--inline\">\\(n-1\\)<\/span> pairs of integers:<\/p>\n<p class=\"mathjax mathjax--block\">\\[\n\\{3, 4\\}, \\{5, 6\\}, \\cdots, \\{2n-1, 2n\\}\\]<\/p>\n<p>which together make up for the whole set <span class=\"mathjax mathjax--inline\">\\(\\{3, 4, \\cdots, 2n-1, 2n\\}\\)<\/span>.\nIf we pick <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> numbers from this set (the pigeons) and if we look for the pairs from where they came (the holes) then we see we <strong>must<\/strong> have picked two consecutive integers from one of the pairs. Those two numbers that came from the same pair are consecutive integers, and hence are coprime!<\/p>\n<p>To see that two consecutive integers are coprime, you can <a href=\"\/blog\/consecutive-integers-are-coprime\">read this twitter proof<\/a>.<\/p>\n<p><a href=\"https:\/\/mathspp.com\/subscribe\">Don't forget to subscribe to the newsletter<\/a> to get bi-weekly\nproblems sent straight to your inbox and to add your reaction below.<\/p>","summary":"A simple problem showing that there is always some order among chaos.","date_modified":"2025-07-23T16:49:02+02:00","tags":["mathematics","number theory","primes"],"image":"\/user\/pages\/02.blog\/03.problems\/p022-coprimes-in-the-crowd\/crowd.jpg"},{"title":"Problem #014 \u2013 the sum of the parts","date_published":"2019-02-12T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/the-sum-of-the-parts","url":"https:\/\/mathspp.com\/blog\/problems\/the-sum-of-the-parts","content_html":"<p>Split the numbers 0, 1, ..., 15 into two sets with sum interesting properties!<\/p>\n\n<p>I got the idea for this problem after attending the <a href=\"https:\/\/ludicum.org\/rmc-vi-2019\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Recreational Maths Colloquium VI<\/a>, where I heard about the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Thue%E2%80%93Morse_sequence\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Thue-Morse sequence<\/a> for the first time in my life.<\/p>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Given the integers <span class=\"mathjax mathjax--inline\">\\(0, 1, \\cdots, 15\\)<\/span>, find a way to split them into two sets <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> such that<\/p>\n<p><span class=\"mathjax mathjax--inline\">\\($\\sum_{a \\in A} a^k = \\sum_{b \\in B} b^k,\\quad k = 0,\\cdots,3\\)<\/span>$<\/p>\n<p>where we define <span class=\"mathjax mathjax--inline\">\\(0^0 = 1\\)<\/span>.<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>This problem is trivial if we know what we are looking for; if not, I would assume this can only be solved by <em>very resilient people<\/em> or by those with the help of a computer.\nNotice that the restriction above, for <span class=\"mathjax mathjax--inline\">\\(k = 0\\)<\/span>, just tells us that the sets <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> have the same number of elements.<\/p>\n<p>Consider this sequence of length <span class=\"mathjax mathjax--inline\">\\(16\\)<\/span>:<\/p>\n<p><span class=\"mathjax mathjax--inline\">\\($ABBABAABBAABABBA\\)<\/span>$<\/p>\n<p>If we identify the sequence with the first <span class=\"mathjax mathjax--inline\">\\(16\\)<\/span> non-negative integers, we get our two sets:<\/p>\n<p><span class=\"mathjax mathjax--inline\">\\($A = \\{0, 3, 5, 6, 9, 10, 12, 15\\}, B = \\{1, 2, 4, 7, 8, 11, 13, 14\\}\\)<\/span>$<\/p>\n<p>Some calculations suffice to show that this is the partition we are looking for:<\/p>\n<p class=\"mathjax mathjax--block\">\\[\n\\begin{align*}\n\\sum_{a \\in A} a^0 &amp;= \\sum_{b \\in B} b^0 = 8 \\\\\n\\sum_{a \\in A} a^1 &amp;= \\sum_{b \\in B} b^1 = 60 \\\\\n\\sum_{a \\in A} a^2 &amp;= \\sum_{b \\in B} b^2 = 620 \\\\\n\\sum_{a \\in A} a^3 &amp;= \\sum_{b \\in B} b^3 = 7200 \\\\\n\\end{align*}\\]<\/p>\n<h2 id=\"bonus-question\">Bonus question<a href=\"#bonus-question\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Find a partition of <span class=\"mathjax mathjax--inline\">\\(0, 1, \\cdots, 31\\)<\/span> into <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> with<\/p>\n<p><span class=\"mathjax mathjax--inline\">\\($\\sum_{a \\in A} a^k = \\sum_{b \\in B} b^k,\\quad k = 0,\\cdots,4\\)<\/span>$<\/p>\n<p>(Notice that now <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span> goes up to <span class=\"mathjax mathjax--inline\">\\(4\\)<\/span>).<\/p>\n<p>Try to generalize your method, so that you can partition the numbers <span class=\"mathjax mathjax--inline\">\\(0, 1, \\cdots, 2^{n+1}-1\\)<\/span> into <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> with<\/p>\n<p><span class=\"mathjax mathjax--inline\">\\($\\sum_{a \\in A} a^k = \\sum_{b \\in B} b^k,\\quad k = 0,\\cdots,n\\)<\/span>$<\/p>\n<p>On the one hand, I feel like this should always possible and I did some calculations that seem to support my claim.\nOn the other hand, I couldn't find any bibliography to support my claim and I wouldn't be surprised if this broke for some value of <span class=\"mathjax mathjax--inline\">\\(k\\)<\/span>.<\/p>","summary":"Split the numbers 0, 1, ..., 15 into two sets with sum interesting properties!","date_modified":"2025-11-22T09:33:35+01:00","tags":["combinatorics","mathematics","number theory"],"image":"\/user\/pages\/02.blog\/03.problems\/p014-the-sum-of-the-parts\/thumbnail.webp"},{"title":"Water buckets riddle","date_published":"2017-11-21T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/water-buckets","url":"https:\/\/mathspp.com\/blog\/water-buckets","content_html":"<p>Can you measure exactly <span class=\"mathjax mathjax--inline\">\\(2\\)<\/span>L of water with two plain buckets with volumes of <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span>L and <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span>L? Of course you can!<\/p>\n\n<figure class=\"image-caption\"><img title=\"Photo by Carolyn V on Unsplash\" alt=\"some gray tin (?) buckets\" src=\"\/user\/pages\/02.blog\/water-buckets\/buckets.jpg\"><figcaption class=\"\">Photo by Carolyn V on Unsplash<\/figcaption><\/figure><p>The way you go about measuring those <span class=\"mathjax mathjax--inline\">\\(2\\)<\/span>L of water is simple:<\/p>\n<ul><li>Pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>fill the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>fill the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>empty the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>fill the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>fill the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one, then<\/li>\n<li>fill the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket, then<\/li>\n<li>pour the <span class=\"mathjax mathjax--inline\">\\(5\\)<\/span> bucket into the <span class=\"mathjax mathjax--inline\">\\(14\\)<\/span> one<\/li>\n<\/ul><p>Piece of cake. Ok, maybe this sequence of moves is annoyingly long but this <em>is<\/em> a relatively well-known riddle and is a really interesting problem, honestly: given <span class=\"mathjax mathjax--inline\">\\(N\\)<\/span> buckets of capacities <span class=\"mathjax mathjax--inline\">\\(c_1, c_2, \\cdots, c_N\\)<\/span>, as well as a target value <span class=\"mathjax mathjax--inline\">\\(T\\)<\/span> and an infinite source of water, is there a sequence of moves that puts exactly <span class=\"mathjax mathjax--inline\">\\(T\\)<\/span> litres in one of the buckets?<\/p>\n<p>There are some cases for which one can immediately say that there is no such sequence. On one hand, if <span class=\"mathjax mathjax--inline\">\\(T &gt; c_i\\ \\forall i\\leq N\\)<\/span>, it is obvious we cannot do so; on the other hand, if such a sequence exists, then <span class=\"mathjax mathjax--inline\">\\(d = \\gcd{(c_1,\\cdots, c_N)} | T\\)<\/span>, i.e., if <span class=\"mathjax mathjax--inline\">\\(T\\)<\/span> is not a multiple of the greatest common divisor <span class=\"mathjax mathjax--inline\">\\(d\\)<\/span> of all the capacities, then the answer is no.<\/p>\n<p>I don't find it obvious that <span class=\"mathjax mathjax--inline\">\\(T\\)<\/span> being a multiple of <span class=\"mathjax mathjax--inline\">\\(d\\)<\/span> is sufficient to prove the existence of a solving sequence, even though we can find integer coefficients <span class=\"mathjax mathjax--inline\">\\(a_i\\)<\/span> such that <span class=\"mathjax mathjax--inline\">\\(a_1c_1 + \\cdots + a_Nc_N = T\\)<\/span> (which would hint on the sequence to be used) it feels like we could not be able to juggle the water in the buckets to hold the intermediate steps needed to get to the final solution.<\/p>\n<p>Even so, it was with astounding ease that I created a script to solve this problem, presenting the sequence of moves when there is a solving sequence and indicating that there is no such sequence when there is no solution. By \"astounding ease\" I mean that I was expecting it to be fairly difficult, but turned out not to be that complicated. I challenge you to try it for yourself. <em>Really<\/em>.<\/p>\n<p>Say we have <span class=\"mathjax mathjax--inline\">\\(N\\)<\/span> ordered buckets. We can represent how much each bucket is filled by a tuple <span class=\"mathjax mathjax--inline\">\\((w_1, \\cdots, w_N)\\)<\/span>. We can now think of all the tuples of length <span class=\"mathjax mathjax--inline\">\\(N\\)<\/span> that could represent a plausible state; that is, we can think of <span class=\"mathjax mathjax--inline\">\\(V = \\{(w_1,\\cdots, w_N) \\in \\mathbb{N}_0^N | w_i \\leq c_i \\}\\)<\/span> as the set of vertices of a directed graph, and then have an edge from <span class=\"mathjax mathjax--inline\">\\(a = (a_1, \\cdots, a_N)\\)<\/span> to <span class=\"mathjax mathjax--inline\">\\(b = (b_1,...<\/span><\/p>","summary":"This post goes over a well known riddle about measuring quantities.","date_modified":"2024-08-13T12:47:46+02:00","tags":["algorithms","graphs","mathematics","programming","python","number theory"],"image":"\/user\/pages\/02.blog\/water-buckets\/buckets.jpg"},{"title":"Problem #002 - a bag full of numbers","date_published":"2017-11-06T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/bag-full-of-numbers","url":"https:\/\/mathspp.com\/blog\/problems\/bag-full-of-numbers","content_html":"<p>Two friends were bored and decided to play a game... a mathematical game with a paper bag!<\/p>\n<!-- v -->\n\n<figure class=\"image-caption\"><img title=\"Photo by B S K from FreeImages\" alt=\"a photo of a paper bag\" src=\"\/images\/5\/4\/c\/9\/b\/54c9b96cd56d5bd47703d53ab49a8a09eb5e1147-paperbag.jpg\"><figcaption class=\"\">Photo by B S K from FreeImages<\/figcaption><\/figure>\n<!-- ^ -->\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>John and Mary have a bag full of integer numbers. In fact, the bag has <span class=\"mathjax mathjax--inline\">\\(10^{10^{10}}\\)<\/span> integers, each written on a plastic card, and the sum of all the <span class=\"mathjax mathjax--inline\">\\(10^{10^{10}}\\)<\/span> integers in the bag is <span class=\"mathjax mathjax--inline\">\\(0\\)<\/span>. In turns, Mary and John are going to play with the bag by doing the following:<\/p>\n<ul>\n<li>Picking two cards from the bag with numbers <span class=\"mathjax mathjax--inline\">\\(a\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(b\\)<\/span> and removing them from the bag;<\/li>\n<li>Inserting a new card in the bag with the number <span class=\"mathjax mathjax--inline\">\\(a^3 + b^3\\)<\/span>.<\/li>\n<\/ul>\n<p>Is there any initial number configuration and\/or set of moves for which it is possible that, after <span class=\"mathjax mathjax--inline\">\\(10^{10^{10}} - 1\\)<\/span> moves, the only card in the bag has the number <span class=\"mathjax mathjax--inline\">\\(73\\)<\/span>?<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought... and most important of all, try it for real! Let me know how it went in the comment section below ;)<\/p>\n<\/div>\n<div class=\"notices green\">\n<p><strong>Hint<\/strong>: the answer is \"no\". Can you show why?<\/p>\n<\/div>\n<div class=\"notices green\">\n<p><strong>Hint<\/strong>: look for an invariant of the game! That is, find a property of the game that does <em>not<\/em> change when Mary and John play it.<\/p>\n<\/div>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>(If you spot a mistake in my solution <em>please<\/em> let me know in the comments below.)<\/p>\n<p>No, there is no initial configuration nor set of moves that allows us to reach the goal. Note how <span class=\"mathjax mathjax--inline\">\\(x \\equiv x^3 \\mod 2\\)<\/span>. That is, <span class=\"mathjax mathjax--inline\">\\(x\\)<\/span> has the same parity as <span class=\"mathjax mathjax--inline\">\\(x^3\\)<\/span>. Let us assume that, at a given point, all the integers in the bag add up to <span class=\"mathjax mathjax--inline\">\\(S\\)<\/span>. We show that the parity of the sum of all integers in the bag doesn't change when we remove the cards <span class=\"mathjax mathjax--inline\">\\(a,b\\)<\/span> and then add the card <span class=\"mathjax mathjax--inline\">\\(a^3+b^3\\)<\/span>:<\/p>\n<p class=\"mathjax mathjax--block\">\\[\n    x \\equiv x^3 \\mod 2 \\implies S \\equiv S - a - b + a^3 + b^3 \\iff S + a + b \\equiv S + a^3 + b^3 \\mod 2\\]<\/p>\n<p>Thus we can't end up only with <span class=\"mathjax mathjax--inline\">\\(73\\)<\/span> in the bag, as everything in the bag should add up to an even number and <span class=\"mathjax mathjax--inline\">\\(73\\)<\/span> is odd.<\/p>\n<p>Bonus question: find a solution that would still work for <span class=\"mathjax mathjax--inline\">\\(2, 74, 308\\)<\/span> (and for an infinity of even numbers), even though those are even.<\/p>","summary":"In this blog post I will challenge you with an interesting problem...","date_modified":"2025-07-23T16:49:02+02:00","tags":["invariants","mathematics","number theory"],"image":"\/user\/pages\/02.blog\/03.problems\/p002-a-bag-full-of-numbers\/paperbag.jpg"},{"title":"Solving diophantine equations with random walks","date_published":"2017-10-29T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/random-walks-diophantine-equations","url":"https:\/\/mathspp.com\/blog\/random-walks-diophantine-equations","content_html":"<p>Here's how I like to solve my equations: just walk around randomly until I trip over a solution!<\/p>\n\n<p><img alt=\"A 3D graph showing the random walk evolution\" src=\"\/images\/c\/2\/e\/f\/5\/c2ef5310f3331f816a89f762538218c2db628093-erdos1all.webp\"><\/p>\n<p>Random walks (check my older post <a href=\"\/blog\/random-walk-simulations\">here<\/a>) and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Diophantine_equation\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Diophantine equations<\/a> are two simple mathematical beasts. After a college seminar, I tried putting them together to make something neat, and came up with this: just pick a Diophantine equation, simulate a random walk, and try to see if the random walk went over any solutions! In <a href=\"https:\/\/drive.google.com\/open\" id=\"0ByBeLS6ciLYVY2hTYU9TV2lUb1k\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">this report<\/a> I briefly go over how I came up with this, and show the code I wrote\/some results. The Matlab code is all in <a href=\"https:\/\/github.com\/RodrigoGiraoSerrao\/projects\/tree\/master\/randomWalks\/diophantineEqs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a> (I also have some Python code about random walks <a href=\"https:\/\/github.com\/RodrigoGiraoSerrao\/projects\/tree\/master\/randomWalks\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a>, check <a href=\"https:\/\/mathspp.blogspot.pt\/2017\/10\/random-walk-simulations.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">my post<\/a>!).<\/p>\n<p>In the image above, the blue line represents a path taken by the random walk and in orange\/red the nodes tell us how far we are from a solution (the smaller the node, the closer we are). Note that this notion of proximity isn't given by actually computing the distance to a known solution, but just by looking at how similar the two sides of the equation are. The image below shows the evolution of three independent random walks trying to find an example solution of <span class=\"mathjax mathjax--inline\">\\(\\frac{4}n = \\frac1x + \\frac1y + \\frac1z\\)<\/span> with <span class=\"mathjax mathjax--inline\">\\(n = 25\\)<\/span> (that expression is the expression of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Erd%C5%91s%E2%80%93Straus_conjecture\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Erd\u00f6s-Straus conjecture<\/a>).<\/p>\n<p><img alt=\"Three random walks in 3D\" src=\"\/user\/pages\/02.blog\/random-walks-diophantine-equations\/erdos25Pos.webp\"><\/p>","summary":"In this post I try to solve some diophantine equations with random walks.","date_modified":"2024-08-13T12:47:46+02:00","tags":["mathematics","programming","diophantine equations","matlab","number theory","simulation","visualisation"],"image":"\/user\/pages\/02.blog\/random-walks-diophantine-equations\/erdos1All.webp"}]}
