Shwetha K. answered 20h
B.S. from Caltech, Math, Essay Writing, and SAT Prep/Test Prep Tutor.
Let's categories the cows by the "state" of life they are in. We assume no cow deaths in 25 years.
An -> For any year n, An represents the number of adult cows (cows actively giving birth, age 2+)
Yn -> For any year n, Yn represents the number of 1 year old cows
Nn -> For any year n, Nn represents the number of newborn cows (cows born that year)
We can use a sort of state machine to find An+1, Yn+1, and Nn+1:
An+1 = An + Yn (last year's adult cows + "graduated" juvenile cows)
Yn+1 = Nn (the previous year's newborn cows, who are all now 1)
Nn+1 = An (each of the previous year's adult cows have had one new baby)
Total cows for year n+1 is An+1 + Yn+1 + Nn+1 = An + Yn + Nn + An
Note that the total number of cows for year n was An + Yn + Nn; Tn+1 = Tn + An
Also note that An = Tn-1, as new babies are only born from cows that were alive two years ago. Therefore, Tn+1 = Tn + Tn-1.
Given starting value of A0 = 1 and T0 = 1, we can just continuously update T (and A/Y/N, if the explanation above was unsatisfying) until year 25. You will find that these values resemble the Fibonacci sequence, which makes sense, as each term in the Fibonacci sequence is the sum of the two preceding terms.