Solve problem 8 using Rust.