{"id":16190,"date":"2016-06-21T18:43:47","date_gmt":"2016-06-21T18:43:47","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=16190"},"modified":"2016-06-21T18:46:58","modified_gmt":"2016-06-21T18:46:58","slug":"math-a-recursive-function-word-problem","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/math-a-recursive-function-word-problem\/","title":{"rendered":"Math:  a recursive function word problem"},"content":{"rendered":"<h1>The tutor shares a solution to a problem from Grimaldi&#8217;s <u>Discrete and Combinatorial Mathematics<\/u>.<\/h1>\n<p>Last night I encountered the problem (p. 481) that paraphrases as follows:<\/p>\n<p>Imagine a car takes two spaces, a motorbike one.  Find a recursive function that determines the number of ways to fill n parking slots with motorbikes and cars (assuming no empty slots).<\/p>\n<p>I played around with the problem for a while, then tried this approach:<\/p>\n<table style=\"width:60%\">\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px;\">Number of slots<\/td>\n<td style=\"text-align:center\">Ways to fill them<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px\">0<\/td>\n<td style=\"text-align:center\">1 (no parking at all)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px\">1<\/td>\n<td style=\"text-align:center\">1 (one motorbike)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px\">2<\/td>\n<td style=\"text-align:center\">2 (2 mbs or 1 car)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px\">3<\/td>\n<td style=\"text-align:center\">3 (3 mbs or 1 car, 1 mb (two ways))<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;border-right:solid; border-width:1px\">4<\/td>\n<td style=\"text-align:right\">5 (4 mbs or 1 car, 2mbs (three ways) or 2 cars)<\/td>\n<\/tr>\n<\/table>\n<p>The right column in the table above is the Fibonacci (F) sequence:  a<sub>n+2<\/sub>=a<sub>n+1<\/sub>+a<sub>n<\/sub>.  However, it&#8217;s advanced by 1:  Typically, F(0)=0, while for this case, F(0)=1.  Fibonacci takes the previous number in the sequence, then adds it to the one before that, to give the current one.<\/p>\n<p>In a coming post I&#8217;ll discuss the general solution to the sequence above:)<\/p>\n<p>Source:<\/p>\n<p>Grimaldi, Ralph P.  <u>Discrete and Combinatorial Mathematics<\/u>.  Don Mills:  Addison-Wesley, 1994.<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor shares a solution to a problem from Grimaldi&#8217;s Discrete and Combinatorial Mathematics. Last night I encountered the problem (p. 481) that paraphrases as follows: Imagine a car takes two spaces, a motorbike one. Find a recursive function that &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/math-a-recursive-function-word-problem\/\"> <span class=\"screen-reader-text\">Math:  a recursive function word problem<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,3],"tags":[1659,1658,1661,1660],"class_list":["post-16190","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-math","tag-discrete-mathematics","tag-fibonacci-sequence","tag-recursive-function","tag-recursive-function-word-problem"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=16190"}],"version-history":[{"count":22,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16190\/revisions"}],"predecessor-version":[{"id":16212,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16190\/revisions\/16212"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=16190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=16190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=16190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}