Updated Algorithms

This commit is contained in:
2021-05-28 16:13:59 -04:00
parent 3dc67e9563
commit 4fe7654d75
2 changed files with 4 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ extern crate myClasses;
use crate::Problems::Answer::Answer;
pub fn getDescription() -> String{
"What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral".to_string()
"What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction?".to_string()
}
pub fn solve() -> Answer{

View File

@@ -55,11 +55,13 @@ pub fn solve() -> Answer{
}
}
let sum = sumOfFifthNumbers.iter().sum::<i64>();
//Stop the timer
timer.stop();
//Return the results
return Answer::new(format!("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is {}", sumOfFifthNumbers.iter().sum::<i64>()), timer.getString(), timer.getNano());
return Answer::new(format!("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is {}", sum), timer.getString(), timer.getNano());
}
//Returns a vector with the individual digits of the number passed to it
fn getDigits(num: i64) -> Vec::<i64>{