1,000 year-old math problem solved