Once upon a time there was a cow. Her name was Mary.

This cow had a friend. It’s good to have friends in life! Her friend was a fly.

They wanted to go from the stable to the meadow, together. The meadow was 5 kms from the stable. Mary, being a cow and all, moved slower than her friend, the fly. She walked at a speed of 1 km/h. The fly, being a fly and all, was hyper-active and never stopped flying. It flew at a speed of 10 kms/h.

Obviously, the fly got to the meadow much faster that Mary. But being hyper-active and a friend, it got back to meet Mary, who had started the walk and was somewhere on the way. Then the fly flew back to the meadow again, and then back to Mary, who had advanced a little more. And it kept doing this until Mary reached the meadow.

Can you tell the total distance that the fly flew?

I’ll give you time to think while I explain my motivation for putting this problem here (and maybe giving you a hint). This problem was proposed by my professor on today’s class. We were studying the formal verification of programs, and after lots of examples and formalities and students sleeping he just went to the black board and started telling Mary’s story. It was quite surprising and he made his point pretty well, which was: the importance of invariants.