Problem 40 (mathematical but needs polishing)