Hello everyone, I'm Xiaohui, a programmer. I haven't published comics on the public account for a long time.
Today's cartoon is adapted from a famous interview question from Google. This problem is a math problem, not very programming related, but very interesting and interesting. Xiao Hui is sharing with you today.
----- the next day -----
————————————
Xiao Hui told Rhubarb about the interview questions she encountered. . . . . . .
Suppose there are n young couples in a region preparing to have children:
If the odds of having a boy and a girl are 50% each, then among the first babies, n/2 will be boys and n/2 will be girls:
According to local customs, families that give birth to boys do not have children, and families that give birth to girls continue to have children. So n/2 families will continue to have children, and in the second batch of newborns, n/4 boys and n/4 girls are added:
By analogy, the remaining n/4 families will continue to give birth. Among the third batch of newborns, n/8 boys and n/8 girls are added:
If it continues, the remaining n/8 families will continue to give birth. Among the fourth batch of newborns, there will be n/16 boys and n/16 girls...