Enter the maze

Programming Puzzle: new naked mole-rats

by Paul Curzon, Queen Mary University of London

Naked Mole Rat Eating

Only the queen of a naked mole-rat colony has pups. They live amazingly long lives and are highly resistant to cancer! Here is a programming puzzle about a fictional colony...

A one-year old queen forms a new colony with a single male. Each year they have a new litter of pups. The number of pups for this queen just so happen to follow a special pattern: 2 pups in the first year, then 3 the next, 5 the next, 8 the next, and so on. This queen dies before any of her pups or the original male.

Write an efficient program to work out the size of her colony after each year if the pattern is followed until she dies (exhausted).

This article funded by ...

Institute of Coding Logo