fn main() { let x: u64 = input_a_value(); let mut v = prime_factors(x); if x == 1 { println!("0"); return; } println!("{}", v.iter().fold(0, |acc, x| acc + x)); } fn input_a_value() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn prime_factors(num: u64) -> Vec { let mut result = num; for i in 2..((num as f64).sqrt() + 1.0) as usize { if num % i as u64 == 0 { result = i as u64; break; } } if result == num { vec![num] } else { let mut v_1 = vec![result]; let mut v_2 = prime_factors(num / result); v_1.append(&mut v_2); v_1 } }