{"id":4057,"date":"2020-04-01T00:01:06","date_gmt":"2020-04-01T07:01:06","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=4057"},"modified":"2020-04-09T13:21:27","modified_gmt":"2020-04-09T20:21:27","slug":"no-nines","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=4057","title":{"rendered":"No Nines!"},"content":{"rendered":"<p>Like many innocent and silly math games, <em>No Nines<\/em> is nerdy to play but fun to code. The game works like this:<br \/>\n<!--more--><br \/>\nThink of a positive integer. If the value is divisible evenly by nine or contains the digit &#8216;9&#8217;, it&#8217;s considered &#8220;illegal.&#8221; All other numbers are legal and valid. Examples:<\/p>\n<p>The integer 19 is illegal because it contains a 9.<br \/>\nThe integer 27 is illegal because it&#8217;s divisible evenly by nine.<br \/>\nThe integer 31 is legal because it doesn&#8217;t contain a 9 and cannot be divided evenly by nine.<\/p>\n<p>Obviously this game becomes more &#8220;fun&#8221; for the nerds when you specify a huge value. Oh, I get all excited thinking about jolly math geeks enjoying a round of <em>No Nines<\/em>.<\/p>\n<p>As a C coder, you need never do math in your head. The computer determines whether an integer is evenly-divisible by nine or contains the digit &#8216;9&#8217;, which is your Exercise for this month:<\/p>\n<p>Write a program that churns through integers 1 to 100. For each value, a test is made to determine whether the integer is evenly divisible by nine or contains the digit &#8216;9&#8217;. If so, the message &#8220;is illegal&#8221; is output along with the reason.<\/p>\n<p>Here is a snippet of output from my solution:<\/p>\n<pre class=\"screen\">\r\n  1 is legal\r\n  2 is legal\r\n  3 is legal\r\n  4 is legal\r\n  5 is legal\r\n  6 is legal\r\n  7 is legal\r\n  8 is legal\r\n  9 is illegal -  divisible by 9 and contains '9'\r\n 10 is legal\r\n 11 is legal\r\n 12 is legal\r\n 13 is legal\r\n 14 is legal\r\n 15 is legal\r\n 16 is legal\r\n 17 is legal\r\n 18 is illegal - divisible by 9\r\n 19 is illegal - contains '9'<\/pre>\n<p>Your task is to write code that generates similar output. Ensure that all values 1 to 100 are scanned and a list is output similar to what&#8217;s shown above. Legal numbers are flagged as such. Illegal values are flagged, along with the reason why it&#8217;s illegal: either because it&#8217;s divisible by nine, contains the digit &#8216;9&#8217;, or both.<\/p>\n<p><a href=\"https:\/\/c-for-dummies.com\/blog\/?p=4062\">Click here<\/a> to view my solution, though please first try this Exercise on your own.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Write a function that determines where an integer is divisible by nine or contains the digit &#8216;9&#8217;, both of which are &#8220;illegal&#8221; conditions. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=4057\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4057","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4057"}],"version-history":[{"count":6,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4057\/revisions"}],"predecessor-version":[{"id":4078,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4057\/revisions\/4078"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}