learning Rust Series: Perfect Number
This will be a part of a series on my rust-learning journey. The goal of this post is to document my process of creating a simple program that determine if the number given is a perfect number1. And also list the perfect number until the given number. Imports 1 use std::io; This is the common input / output modules. Function to determine the perfect number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 fn is_perfect_number(n: i32) -> bool { let mut sum: i32 = 1; let mut i: i32 = 2; while i * i <= n { if n % i == 0 { sum = sum + i + n / i; } i += 1; } if sum == n && n !...