diff --git a/src/bin/powerful_digit_sum.rs b/src/bin/powerful_digit_sum.rs new file mode 100644 index 0000000..b6e7522 --- /dev/null +++ b/src/bin/powerful_digit_sum.rs @@ -0,0 +1,14 @@ +use num_bigint::BigUint; + +fn main() { + let mut sums: Vec = vec![]; + + for i in 1..100 { + for j in 1..100 { + let power = format!("{}", BigUint::from(i as u64).pow(j)); + sums.push(power.chars().filter_map(|c| c.to_digit(10)).sum()); + } + } + + println!("{}", sums.iter().max().unwrap()); +}