Solve problem 21 using Rust.