solutions: 12
This commit is contained in:
parent
83b2aa0782
commit
ae22f6ab8c
26
highly_divisible_triangular_number.rs
Normal file
26
highly_divisible_triangular_number.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
pub fn factors(num: u64) -> Vec<u64> {
|
||||
let mut factors: Vec<u64> = Vec::new();
|
||||
for i in 1..((num as f64).sqrt() as u64 + 1) {
|
||||
if num % i == 0 {
|
||||
factors.push(i);
|
||||
if i != num / i {
|
||||
factors.push(num / i);
|
||||
}
|
||||
}
|
||||
}
|
||||
factors
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut triangular_increment: u64 = 0;
|
||||
let mut triangular: u64 = 0;
|
||||
|
||||
while factors(triangular).len() <= 500 {
|
||||
triangular = 0;
|
||||
for i in 1..=triangular_increment {
|
||||
triangular += i;
|
||||
}
|
||||
triangular_increment += 1;
|
||||
}
|
||||
println!("{}", triangular);
|
||||
}
|
Loading…
Reference in a new issue