chore: rustfmt
This commit is contained in:
parent
add6f2403c
commit
b7c61ccef8
|
@ -26,5 +26,5 @@ fn main() {
|
||||||
increment += 1;
|
increment += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:?}", primes[primes.len()-1]);
|
println!("{:?}", primes[primes.len() - 1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut sequence: Vec<i32> = vec![1, 2];
|
let mut sequence: Vec<i32> = vec![1, 2];
|
||||||
while sequence[sequence.len()-1] <= 4000000 {
|
while sequence[sequence.len() - 1] <= 4000000 {
|
||||||
let mut last = sequence[sequence.len()-1];
|
let mut last = sequence[sequence.len() - 1];
|
||||||
let mut secondlast = sequence[sequence.len()-2];
|
let mut secondlast = sequence[sequence.len() - 2];
|
||||||
(secondlast, last) = (last, secondlast+last);
|
(secondlast, last) = (last, secondlast + last);
|
||||||
sequence.push(last);
|
sequence.push(last);
|
||||||
}
|
}
|
||||||
for i in sequence.clone() {
|
for i in sequence.clone() {
|
||||||
if i % 2 != 0 || i > 4000000 {
|
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();
|
let sum: i32 = sequence.iter().sum();
|
||||||
|
|
|
@ -3,11 +3,11 @@ fn main() {
|
||||||
|
|
||||||
for i in 1..=999 {
|
for i in 1..=999 {
|
||||||
for j 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>();
|
let reversed_string = product_string.chars().rev().collect::<String>();
|
||||||
|
|
||||||
if i*j > product && reversed_string == product_string {
|
if i * j > product && reversed_string == product_string {
|
||||||
product = i*j;
|
product = i * j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ fn main() {
|
||||||
for k in 1..1000 {
|
for k in 1..1000 {
|
||||||
let pythagoras: f64 = (i as f64).powf(2.) + (j as f64).powf(2.);
|
let pythagoras: f64 = (i as f64).powf(2.) + (j as f64).powf(2.);
|
||||||
if pythagoras == (k as f64).powf(2.) {
|
if pythagoras == (k as f64).powf(2.) {
|
||||||
if i+j+k == 1000 {
|
if i + j + k == 1000 {
|
||||||
println!("{}", i*j*k);
|
println!("{}", i * j * k);
|
||||||
break 'algorithm;
|
break 'algorithm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ fn main() {
|
||||||
let mut total1: u64 = 0;
|
let mut total1: u64 = 0;
|
||||||
|
|
||||||
for i in 1..=100 {
|
for i in 1..=100 {
|
||||||
total += i*i;
|
total += i * i;
|
||||||
total1 += i;
|
total1 += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
let square_sum = total1.pow(2);
|
let square_sum = total1.pow(2);
|
||||||
let difference = square_sum-total;
|
let difference = square_sum - total;
|
||||||
|
|
||||||
println!("{}", difference);
|
println!("{}", difference);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue