Solve problem 22 using Rust.