Bunnies Download

Christina Cacioppo

for loops, recursion Student approved


Introduction

Imagine this: last January 1, you went for a walk and found a pair of magic bunnies. You decided to take them home.

On the bunnies' two-month birthday, they gave birth to another pair of magic bunnies. Then, every month after, each bunny pair bore another pair.

By the end of the year – 12 months later – how many pairs of bunnies will you have?


Task

Complete the bunniesIn(month) function. It should tell us how many pairs of bunnies you'll have in a given month.


Starter code

class Bunny{
	public static void main(String[] args){
		int pairs = bunniesIn(11);
		System.out.println("There are " + pairs + " pairs of bunnies in November");
	}

	static int bunniesIn(int month){
		/*		Your code here		*/		
	}	
}

Expected output

As written, the program will produce:

There are 89 pairs of bunnies in November

As well, here's a table with the number of bunny pairs for each month of the first 12:
MonthBunny pairs
11
21
32
43
55
68
713
821
934
1055
1189
12144

One solution


Useful tools to solve the problem