{"id":7039,"date":"2024-08-19T03:00:00","date_gmt":"2024-08-19T07:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=7039"},"modified":"2024-08-13T16:56:03","modified_gmt":"2024-08-13T20:56:03","slug":"count-magic-bunnies-in-libreoffice-calc","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=7039","title":{"rendered":"Count magic bunnies in LibreOffice Calc"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"7039\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>I love working in spreadsheets, and my favorite spreadsheet is <a href=\"https:\/\/www.libreoffice.org\/\">LibreOffice Calc<\/a>. I can use spreadsheets to do all kinds of work, as long as it involves a calculation.<\/p>\n\n\n\n<p>One power feature of modern spreadsheets is \u201cAutoFill.\u201d That\u2019s where you can enter a calculation in a cell, then click on it, and use the little \u201cdrag handle\u201d (in the lower right of the cell) to <em>extend<\/em> the calculation to adjacent cells. Spreadsheets have had a \u201ctranslate calculations to other cells\u201d feature since VisiCalc, the first desktop spreadsheet &#8211; but the \u201cAutoFill\u201d feature makes this easier and more transparent.<\/p>\n\n\n\n<p>Let\u2019s do a simple calculation to demonstrate how AutoFill works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-magic-bunny\">The magic bunny<\/h2>\n\n\n\n<p>Imagine an enchanted forest, which happens to have zero bunnies. Then one day, a magic bunny moves in. Rabbits breed quickly, but especially so for the magic breed of bunny. The magic bunny is already pregnant &#8211; it is born pregnant &#8211; and all its children will also be born pregnant. The bunny produces a new generation of more magical bunnies once a year.<\/p>\n\n\n\n<p>Let\u2019s refer to the year <em>before<\/em> the bunny moved in as \u201cyear zero,\u201d or \u201citeration zero,\u201d when there were no bunnies in the forest. A year later, we\u2019re at \u201cyear one\u201d or \u201citeration one,\u201d with our first bunny.<\/p>\n\n\n\n<p>The population of the magic bunny grows like this: A baby bunny grows into an adult bunny after just one year. An adult bunny will continue to the next generation, but will produce another baby bunny of its own. We can track this iteration of bunnies by using the letter <strong>b<\/strong> for a baby bunny and the letter <strong>A<\/strong> for an adult bunny. In \u201cyear zero,\u201d there\u2019s nothing, but in \u201cyear 1\u201d we have a baby bunny (b). Then the population grows like this:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>b<\/li>\n\n\n\n<li>A<\/li>\n\n\n\n<li>A b<\/li>\n\n\n\n<li>A b A<\/li>\n\n\n\n<li>A b A A b<\/li>\n<\/ol>\n\n\n\n<p>\u2026 and so on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"counting-bunnies-in-a-spreadsheet\">Counting bunnies in a spreadsheet<\/h2>\n\n\n\n<p>As you can see, the bunny population grows quickly. In just a few years, the forest will quickly be filled with magic bunnies. How many bunnies will we have after 5, 10, or 20 years?<\/p>\n\n\n\n<p>Italian mathematician Fibonacci modeled this population growth using an equation. Looking at iteration, the number of bunnies in any generation is the <em>sum<\/em> of the two previous generations. In other words:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><em>F<\/em><em>i<\/em><em>b<\/em>(<em>n<\/em>)\u2004=\u2004<em>F<\/em><em>i<\/em><em>b<\/em>(<em>n<\/em>\u22121)\u2005+\u2005<em>F<\/em><em>i<\/em><em>b<\/em>(<em>n<\/em>\u22122)<\/p>\n\n\n\n<p>\u2026 where <em>F<\/em><em>i<\/em><em>b<\/em>(0)\u2004=\u20040 and <em>F<\/em><em>i<\/em><em>b<\/em>(1)\u2004=\u20041.<\/p>\n\n\n\n<p>This is pretty easy to calculate in a spreadsheet. Open LibreOffice Calc can enter the first two iterations: 0 and 1. Let\u2019s create the <strong>iteration<\/strong> or <em>n<\/em> in column A, and the <strong>count<\/strong> or <em>F<\/em><em>i<\/em><em>b<\/em>(<em>n<\/em>) in column B.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"145\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib1.png\" alt=\"\" class=\"wp-image-7040\"\/><\/figure>\n\n\n\n<p>For the first two iterations: year zero had 0 bunnies; year one had 1 bunny. Enter 0 in cell <code>A2<\/code> and 0 in <code>B2<\/code> for year zero, and enter 1 in cell <code>A3<\/code> and 1 in <code>B3<\/code> for year one.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"145\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib2.png\" alt=\"\" class=\"wp-image-7041\"\/><\/figure>\n\n\n\n<p>With these values, we can enter the Fibonacci formula for the next year. Because the count in each successive year is the sum of the two previous years, we can enter this calculation in cell <code>B4<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>=B2+B3<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"145\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib3.png\" alt=\"\" class=\"wp-image-7042\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"now-the-magic-happens\">Now the magic happens<\/h2>\n\n\n\n<p>Having entered 0 and 1 in column A to represent year zero and year one, we can let AutoFill do the rest of the work for us. With your mouse, highlight cells <code>A2<\/code> and <code>A3<\/code> by clicking on <code>A2<\/code> and <em>keep holding down the mouse button<\/em> as you move the mouse into cell <code>A3<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"145\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib4.png\" alt=\"\" class=\"wp-image-7043\"\/><\/figure>\n\n\n\n<p>Do you see the heavy \u201cdot\u201d in the lower right corner of <code>A3<\/code>? That\u2019s the \u201cgrab handle\u201d that you can use to extend this sequence of two cells into adjacent cells. Drag the \u201cdot\u201d down into the next few cells until you fill 20 years. The AutoFill feature will detect the <em>step<\/em> between 0 and 1 is 1, and increment each successive year by 1.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"470\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib5.png\" alt=\"\" class=\"wp-image-7044\"\/><\/figure>\n\n\n\n<p>Now click in cell <code>A4<\/code> where we entered the Fibonacci calculation. Drag the \u201cgrab handle\u201d downwards and let AutoFill continue the calculation through year 20. In each successive year, AutoFill will translate the calculation so that each new calculation is the <em>sum of the two cells above it<\/em>. That\u2019s how AutoFill makes it easy!<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"470\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/08\/fib6.png\" alt=\"\" class=\"wp-image-7045\"\/><\/figure>\n\n\n\n<p>And with that, we see that after 20 iterations, the forest will have 6,765 magic bunnies. That\u2019s a lot of bunnies! Over 6,000 bunnies in 20 years represents a very fast population growth, and demonstrates how the Fibonacci sequence can add up quickly. Yet the calculation was made simple using AutoFill and LibreOffice Calc.<\/p>\n\n\n\n<p><em>This article is adapted from <a href=\"https:\/\/opensource.com\/article\/23\/1\/count-magical-bunnies-libreoffice-calc\">Count magical bunnies with LibreOffice Calc<\/a> by Jim Hall, and is republished here with the author&#8217;s permission.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use this tutorial to learn about AutoFill in LibreOffice Calc.<\/p>\n","protected":false},"author":33,"featured_media":3096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[237],"tags":[133],"class_list":["post-7039","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-libreoffice","tag-libreoffice"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7039"}],"version-history":[{"count":1,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7039\/revisions"}],"predecessor-version":[{"id":7046,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7039\/revisions\/7046"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/3096"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}