Recursion We have a number of bunnies and each bunny has two big floppy ears. We want to compute the total number of ears across all the bunnies recursively (without loops or multiplication). Write a function called bunny_ears that takes the number of bunnies as a parameter and recursively counts and returns the number of bunny ears. Recursion con't e.g. >>> ears = bunny_ears(0) print(ears)
Added by Tiffany C.
Close
Step 1
If the number of bunnies is 0, then the total number of ears is also 0. Show more…
Show all steps
Your feedback will help us improve your experience
Ankit Gupta and 61 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
(IMAGE NOT COPY) Rabbit Population Growth. One of the most famous recursively defined sequences is the Fibonacci sequence. In 1202 , the Italian mathematician Leonardo da Pisa, also called Fibonacci, proposed the following model for rabbit population growth. Suppose that every month each mature pair of rabbits in the population produces a new pair that begins reproducing after two months, and also suppose that no rabbits die. Beginning with one pair of newborn rabbits, the population can be modeled by the following recursively defined sequence:
Sequences, Series, and Combinatorics
Sequences and Series
One of the most famous recursively defined sequences is the Fibonacci sequence. In $1202,$ the Italian mathematician Leonardo da Pisa, also called Fibonacci, proposed the following model for rabbit population growth. Suppose that every month each mature pair of rabbits in the population produces a new pair that begins reproducing after two months, and also suppose that no rabbits die. Beginning with one pair of newborn rabbits, the population can be modeled by the following recursively defined sequence: $a_{1}=1, a_{2}=1, a_{n}=a_{n-1}+a_{n-2},$ for $n \geq 3$ where $a_{n}$ is the total number of pairs of rabbits in month $n .$ Find the first 7 terms of the Fibonacci sequence. (PICTURE NOT COPY)
Fibonacci posed the following problem: Suppose rabbits live forever and that every month each pair produces a new pair which becomes productive at age 2 months. If we start with one newborn pair, how many pairs of rabbits will we have in the nth month? Clearly explain your reasoning and find the recursive formula ( a_n = ) that describes how many pairs we have after n months. Let n be the number of months and n begins with n = 1. (No credit for formula only. How did you arrive at your answer?)
Pavi S.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD