chore: rustfmt
This commit is contained in:
parent
add6f2403c
commit
b7c61ccef8
|
@ -26,5 +26,5 @@ fn main() {
|
|||
increment += 1;
|
||||
}
|
||||
|
||||
println!("{:?}", primes[primes.len()-1]);
|
||||
println!("{:?}", primes[primes.len() - 1]);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
fn main() {
|
||||
let mut sequence: Vec<i32> = 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();
|
||||
|
|
|
@ -3,11 +3,11 @@ fn main() {
|
|||
|
||||
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::<String>();
|
||||
|
||||
if i*j > product && reversed_string == product_string {
|
||||
product = i*j;
|
||||
if i * j > product && reversed_string == product_string {
|
||||
product = i * j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ fn main() {
|
|||
let mut factors: Vec<u64> = 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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue