diff --git a/040/main.rs b/040/main.rs new file mode 100644 index 0000000..eaa7e74 --- /dev/null +++ b/040/main.rs @@ -0,0 +1,23 @@ +use std::str::FromStr; + +fn ts(k: usize, s: &String) -> u32 { + u32::from_str(s.chars().nth(k).unwrap().to_string().as_str()).unwrap() +} + +fn main() { + let mut res = String::from("0"); + let mut k = 1usize; + while res.len() < 1000001 { + res.push_str(k.to_string().as_str()); + k += 1; + } + + println!("{}", ts(9, &res)); + let mut prod = 1; + let mut i = 1; + while i <= 1000000 { + prod *= ts(i, &res); + i *= 10; + } + println!("{}", prod); +}