diff --git a/10001st_prime.rs b/10001st_prime.rs index ef595ad..c20abc9 100644 --- a/10001st_prime.rs +++ b/10001st_prime.rs @@ -26,5 +26,5 @@ fn main() { increment += 1; } - println!("{:?}", primes[primes.len()-1]); + println!("{:?}", primes[primes.len() - 1]); } diff --git a/even_fibonacci_numbers.rs b/even_fibonacci_numbers.rs index e13d183..b13e6eb 100644 --- a/even_fibonacci_numbers.rs +++ b/even_fibonacci_numbers.rs @@ -1,14 +1,19 @@ fn main() { let mut sequence: Vec = vec![1, 2]; - while sequence[sequence.len()-1] <= 4000000 { - let mut last = sequence[sequence.len()-1]; - let mut secondlast = sequence[sequence.len()-2]; - (secondlast, last) = (last, secondlast+last); + while sequence[sequence.len() - 1] <= 4000000 { + let mut last = sequence[sequence.len() - 1]; + let mut secondlast = sequence[sequence.len() - 2]; + (secondlast, last) = (last, secondlast + last); sequence.push(last); } for i in sequence.clone() { if i % 2 != 0 || i > 4000000 { - sequence.remove(sequence.iter().position(|x| *x == i).expect("Item not found")); + sequence.remove( + sequence + .iter() + .position(|x| *x == i) + .expect("Item not found"), + ); } } let sum: i32 = sequence.iter().sum(); diff --git a/highly_divisible_triangular_number.rs b/highly_divisible_triangular_number.rs index 338785a..787dd50 100644 --- a/highly_divisible_triangular_number.rs +++ b/highly_divisible_triangular_number.rs @@ -14,7 +14,7 @@ pub fn factors(num: u64) -> Vec { 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 { diff --git a/largest_palindrome_product.rs b/largest_palindrome_product.rs index e5cb3d0..4121c08 100644 --- a/largest_palindrome_product.rs +++ b/largest_palindrome_product.rs @@ -1,16 +1,16 @@ fn main() { - let mut product: i64 = 0; + let mut product: i64 = 0; for i in 1..=999 { for j in 1..=999 { - let product_string: String = format!("{:?}", i*j); + let product_string: String = format!("{:?}", i * j); let reversed_string = product_string.chars().rev().collect::(); - if i*j > product && reversed_string == product_string { - product = i*j; + if i * j > product && reversed_string == product_string { + product = i * j; } } } - + println!("{}", product); } diff --git a/largest_prime_factor.rs b/largest_prime_factor.rs index a7040f8..9a65ce8 100644 --- a/largest_prime_factor.rs +++ b/largest_prime_factor.rs @@ -3,12 +3,12 @@ fn main() { let mut factors: Vec = vec![]; let mut i: u64 = 2; while i.pow(2) <= num { - if num % i == 0 { - factors.push(i); - num = (num as f64 / i as f64).floor() as u64; - } else { - i += 1; - } + if num % i == 0 { + factors.push(i); + num = (num as f64 / i as f64).floor() as u64; + } else { + i += 1; + } } if num != 1 { factors.push(num); diff --git a/special_pythagorean_triplet.rs b/special_pythagorean_triplet.rs index 3267fe1..e71c330 100644 --- a/special_pythagorean_triplet.rs +++ b/special_pythagorean_triplet.rs @@ -5,8 +5,8 @@ fn main() { for k in 1..1000 { let pythagoras: f64 = (i as f64).powf(2.) + (j as f64).powf(2.); if pythagoras == (k as f64).powf(2.) { - if i+j+k == 1000 { - println!("{}", i*j*k); + if i + j + k == 1000 { + println!("{}", i * j * k); break 'algorithm; } } diff --git a/sum_square_difference.rs b/sum_square_difference.rs index b8dd0fc..6a37628 100644 --- a/sum_square_difference.rs +++ b/sum_square_difference.rs @@ -3,12 +3,12 @@ fn main() { let mut total1: u64 = 0; for i in 1..=100 { - total += i*i; + total += i * i; total1 += i; } let square_sum = total1.pow(2); - let difference = square_sum-total; + let difference = square_sum - total; println!("{}", difference); }