{"id":728,"date":"2024-01-29T16:28:50","date_gmt":"2024-01-29T16:28:50","guid":{"rendered":"http:\/\/bacon.umcs.lublin.pl\/~wolsk\/?page_id=728"},"modified":"2024-01-30T11:39:24","modified_gmt":"2024-01-30T11:39:24","slug":"human-problem-solving-test-2024","status":"publish","type":"page","link":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/?page_id=728","title":{"rendered":"Human Problem Solving Project 2024"},"content":{"rendered":"\n<p>From Wikipedia, the free encyclopedia:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Number_theory\">number theory<\/a>,&nbsp;<strong>Fermat&#8217;s little theorem<\/strong>&nbsp;states that if&nbsp;<em>p<\/em>&nbsp;is a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Prime_number\">prime number<\/a>, then for any&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Integer\">integer<\/a>&nbsp;<em>a<\/em>, the number&nbsp;<em>a<\/em><sup><em>p<\/em><\/sup>&nbsp;\u2212&nbsp;<em>a<\/em>&nbsp;is an integer multiple of&nbsp;<em>p<\/em>. In the notation of&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Modular_arithmetic\">modular arithmetic<\/a>, this is expressed as:<\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/wikimedia.org\/api\/rest_v1\/media\/math\/render\/svg\/76fcf163a7523f30b84bf09165eba0092b0ee32e\" alt=\"{\\displaystyle a^{p}\\equiv a{\\pmod {p}}.}\"><\/p>\n\n\n\n<p>If one wants to test whether&nbsp;<em>p<\/em>&nbsp;is prime, then we can pick random integers&nbsp;<em>a<\/em>&nbsp;and see whether the congruence holds.&nbsp;If it does not hold for a value of&nbsp;<em>a<\/em>, then&nbsp;<em>p<\/em>&nbsp;is composite. This congruence is unlikely to hold for a random&nbsp;<em>a<\/em>&nbsp;if&nbsp;<em>p<\/em>&nbsp;is composite. Therefore, if the equality does hold for one or more values of&nbsp;<em>a<\/em>, then we say that&nbsp;<em>p<\/em>&nbsp;is&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Probable_prime\">probably prime<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Please<strong> write a probabilistic program based on Fermat&#8217;s little theorem checking if a given number is prime<\/strong>. Use &#8220;random&#8221; function, which returns a random number from zero to n &#8211; 1, e.g. (random 5) may return 0, 1, 2, 3, or 4. Please, <strong>write also the standard deterministic program based on the well-known definition:<\/strong><\/p>\n\n\n\n<p><strong>A prime number is<\/strong>&nbsp;<strong>a number that can only be divided by itself and 1 without remainders<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Let&#8217;s assume that 100 Fermat&#8217;s tests is enough to be sure if the number is prime. <strong>Which program is theoretically better and which performs better in real life? Can you guess why?<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From Wikipedia, the free encyclopedia: In&nbsp;number theory,&nbsp;Fermat&#8217;s little theorem&nbsp;states that if&nbsp;p&nbsp;is a&nbsp;prime number, then for any&nbsp;integer&nbsp;a, the number&nbsp;ap&nbsp;\u2212&nbsp;a&nbsp;is an integer multiple of&nbsp;p. In the notation of&nbsp;modular arithmetic, this is expressed as: If one wants to test whether&nbsp;p&nbsp;is prime, then we can pick random integers&nbsp;a&nbsp;and see whether the congruence holds.&nbsp;If it does not hold for a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/?page_id=728\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Human Problem Solving Project 2024&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/pages\/728"}],"collection":[{"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=728"}],"version-history":[{"count":6,"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/pages\/728\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=\/wp\/v2\/pages\/728\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/bacon.umcs.lublin.pl\/~wolsk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}