FWIW I've had this same question in an interview years ago in Australia. Don't recall seeing the second part (which is more interesting, mathematically), but it just goes to show how many questions end up re-used by different companies as their employees travel.