solutions: 40
This commit is contained in:
parent
74e9647bd9
commit
48fe778c50
1 changed files with 16 additions and 0 deletions
16
src/bin/champernownes_constant.rs
Normal file
16
src/bin/champernownes_constant.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
fn main() {
|
||||
let mut string: String = "0.".to_string();
|
||||
for i in 1..=185185 {
|
||||
string.push_str(&i.to_string());
|
||||
}
|
||||
|
||||
let digits = vec![1, 10, 100, 1000, 10_000, 100_000, 1_000_000];
|
||||
let mut multiplying: Vec<u32> = vec![];
|
||||
|
||||
for i in digits {
|
||||
let digit = &string.chars().nth(i+1);
|
||||
multiplying.push(digit.unwrap().to_digit(10).unwrap());
|
||||
}
|
||||
|
||||
println!("{}", multiplying.iter().product::<u32>());
|
||||
}
|
Loading…
Reference in a new issue