Sharks might not win any prizes for smarts, but they often behave like brilliant mathematicians.