{"id":355,"date":"2007-08-19T13:03:15","date_gmt":"2007-08-19T20:03:15","guid":{"rendered":"http:\/\/www.elbeno.com\/blog\/?p=355"},"modified":"2007-08-19T13:03:15","modified_gmt":"2007-08-19T20:03:15","slug":"exploring-pascals-triangle","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/blog\/?p=355","title":{"rendered":"Exploring Pascal&#8217;s Triangle"},"content":{"rendered":"<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Pascal%27s_triangle\">Pascal&#8217;s Triangle<\/a> (henceforth known as PT). You know &#8211; that thing you learned in maths. The Wikipedia entry, like most mathematical Wikipedia entries, reads (if your mathematical background is anything like mine) like &#8220;here&#8217;s a few things you might vaguely remember from school, oh and of course gleep = glorp&#8221;. Although I have to say, the PT entry is less opaque than most.<\/p>\n<p>If you were lucky enough to have a &#8220;recreational maths&#8221; class then perhaps you studied PT more. I did have a recreational maths class in the 4th form (erm&#8230; <a href=\"http:\/\/www.education-otherwise.org\/Trivia\/UK-US%20Comparison%20Chart.htm\">7th grade<\/a>? I went to a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Independent_school_%28UK%29\">public school<\/a> with a nonstandard year numbering), but at the time I didn&#8217;t appreciate just how much higher level mathematics is intertwined (see trigonometry, complex numbers &amp; calculus). Also, is it just me, or are curricula in general a bit light on actual number theory? I mean, we learn counting, and times tables, but after that it gets a bit fuzzy. Prime numbers? Some cursory investigation. But ISTM that students don&#8217;t really get to know the normal counting numbers very well. At least, I didn&#8217;t. I remember the occasions where we did take a lesson &#8220;off the curriculum&#8221; to study them as being some of my favourite maths lessons, e.g. the Hotel Cantor with a room for every positive integer, and the Infinity Bus Line which had a bus for every positive integer, each of which had a seat for every positive integer.<\/p>\n<p>Anyway, PT. The thing I knew about but didn&#8217;t appreciate the significance of. Over the last week I&#8217;ve been tackling the <a href=\"http:\/\/projecteuler.net\/\">Project Euler<\/a> problems and there are a few concerning PT. (There are many inviting an exploration of number theory, which is also very cool). After solving 34%, I decided to skip down to <a href=\"http:\/\/projecteuler.net\/index.php?section=problems&amp;id=148\">problem 148<\/a>, &#8220;Exploring Pascal&#8217;s Triangle&#8221;. Not many people have solved this, I thought: daunting! But also, this is my old friend PT. I&#8217;d like to get to know it better.<\/p>\n<p>So after a couple of days of head scratching, I realised a way to attack the problem which would terminate before the heat death of the universe (always a useful approach to take). I also coded up some naive programs just to start exploring PT (as the problem says) &#8211; in the hope that they would give me some insight. Well, that and 3 or 4 pages of diagramming and scribbling later, I found out some quite interesting things. And I realised that I could solve the problem not just for multiples of 7, but for multiples of any prime. Now that&#8217;s cool.<\/p>\n<p>I coded up a solution and ran it. It produced the wrong answer. I realised I&#8217;d missed something and corrected it. It produced the wrong answer. I tried again. Wrong answer. So I went to bed. Next morning, I realised my error, and also that I could simplify the program and speed it up. I coded it up again, and after ironing out a few non-algorithmic bugs, I ran it. Hooray! The right answer! I join the club of people who have solved problem 148.<\/p>\n<p>Maths is cool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pascal&#8217;s Triangle (henceforth known as PT). You know &#8211; that thing you learned in maths. The Wikipedia entry, like most mathematical Wikipedia entries, reads (if your mathematical background is anything like mine) like &#8220;here&#8217;s a few things you might vaguely remember from school, oh and of course gleep = glorp&#8221;&#8230;.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,8],"tags":[],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-maths","category-programming"],"_links":{"self":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}