Solve problem 27 using Rust.