Contents
Problem
Solution
費氏數列:
M:male, F:female
Both male and female need a mom: F(n) = F(n-1) + M(n-1)
Only female need a dad: M(n) = F(n-1)
F(n) = F(n-1) + F(n-2)
n generation:
M(n) + F(n) = F(n-1) + F(n)
Code
1 |
|
費氏數列:
M:male, F:female
Both male and female need a mom: F(n) = F(n-1) + M(n-1)
Only female need a dad: M(n) = F(n-1)
F(n) = F(n-1) + F(n-2)
n generation:
M(n) + F(n) = F(n-1) + F(n)
1 |
|