Solve problem 5 using Rust.