{"id":5526,"date":"2011-01-02T16:25:47","date_gmt":"2011-01-02T21:25:47","guid":{"rendered":"http:\/\/blog.kenperlin.com\/?p=5526"},"modified":"2011-01-02T19:34:59","modified_gmt":"2011-01-03T00:34:59","slug":"prime-directive","status":"publish","type":"post","link":"http:\/\/blog.kenperlin.com\/?p=5526","title":{"rendered":"Prime directive"},"content":{"rendered":"<p>I was quite excited at the prospect that 2011 might be a prime number.  I happened to be at my computer, but not on the internet, so I wrote a little computer program to run through the factors of 2011.  If a number has no factors other than itself and 1, then it is prime.<\/p>\n<p>Sure enough, my program told me that 2011 is indeed a prime year.  Yay!<\/p>\n<p>Of course the moment I got on-line, I could just Google it, using <b>2011<\/b> and <b>prime<\/b> as the search words.  Sure enough, 2011 pops up on the very first hit (Wikipedia&#8217;s list of the first 1000 prime numbers).<\/p>\n<p>The program was very simple (it took maybe 30 seconds to write), but I find it sad that I can&#8217;t easily share my joy of discovery, since unless you already know Java, the code I wrote will look to you like gobbledygook:<\/p>\n<p>      &nbsp;&nbsp;&nbsp; <font face=courier>for (int i = 1 ; i <= 2011 ; i++)\n      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (2011 % i == 0)\n      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(i);<\/font><\/p>\n<p>If I translate this into a friendlier looking programming language, it might look like this:<\/p>\n<p>        &nbsp;&nbsp;&nbsp; <font face=courier>for every <b>I<\/b> from <b>1<\/b> through <b>2011<\/b><br \/>\n           &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;if <b>2011<\/b> mod <b>I<\/b> is <b>0<\/b><br \/>\n               &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print <b>I<\/b><\/font><\/p>\n<p>That&#8217;s almost ok, except that people who don&#8217;t already know programming will get stuck at that second line.  So let&#8217;s replace it with something even friendlier:<\/p>\n<p>        &nbsp;&nbsp;&nbsp; <font face=courier>for every <b>I<\/b> from <b>1<\/b> through <b>2011<\/b><br \/>\n            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if <b>2011<\/b> is divisible by <b>I<\/b><br \/>\n               &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print <b>I<\/b><\/font><\/p>\n<p>Ah, that&#8217;s more like it!  Meanwhile, if you&#8217;re a more advanced programmer, you can peek to see how the computer is told what &#8220;is divisible by&#8221; means, again in this friendly computer language:<\/p>\n<p>        &nbsp;&nbsp;&nbsp; <font face=courier><b>A<\/b> is divisible by <b>B<\/b> means<br \/>\n            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;the remainder of <b>A<\/b> divided by <b>B<\/b> is <b>0<\/b><\/font><\/p>\n<p>Now we have something that anybody reading this blog can understand.  And in my mind that was actually the program I wrote &#8212; except that as I typed the program, I automatically changed it into Java programming, sort of the way a pianist might transpose music from one key to another.<\/p>\n<p>Maybe it would be a good idea to make it very easy to create these sorts of conversational programming <a href=http:\/\/en.wikipedia.org\/wiki\/Mad_Libs target=1>Mad Libs<\/a> (such as: &#8220;for every &#8212; from &#8212; to &#8212; &#8221; or &#8220;the remainder of &#8212; divided by &#8212; &#8220;).  Then it would be easy to write a program that anybody at all could read (or maybe even write), but which would still run on a computer.<\/p>\n<p>Maybe we should hurry up and do that, while it&#8217;s still a prime numbered year. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was quite excited at the prospect that 2011 might be a prime number. I happened to be at my computer, but not on the internet, so I wrote a little computer program to run through the factors of 2011. If a number has no factors other than itself and 1, then it is prime. &hellip; <a href=\"http:\/\/blog.kenperlin.com\/?p=5526\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Prime directive&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5526"}],"collection":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5526"}],"version-history":[{"count":34,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5526\/revisions"}],"predecessor-version":[{"id":5560,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5526\/revisions\/5560"}],"wp:attachment":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5526"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}