Solve problem 46 using Rust.