A pair of newborn rabbits begins mating at age 1 month and thereafter produces o
ID: 3530301 • Letter: A
Question
A pair of newborn rabbits begins mating at age 1 month and thereafter produces one pair of offspring per month. If we start with a newly born pair of rabbits, how many rabbits will there be at the beginning of each month?
Fibonacci offered a solution:
Month: 0 1 2 3 4 5 6 7 . . .. . . . . m
Pairs: 1 1 2 3 5 8 13 21 . . . .. . ..P_m = P_m-1 + P_m-2
Write a program that prompts the user for an integer m, then prints the mth Fibonacci number. Your program should print an appropriate error message if the user enters a negative number.