finish 16

This commit is contained in:
Dr. Matthias Ratajczak
2022-08-19 15:49:44 +02:00
parent 6fa6ab62e6
commit 6f8e78e112
2 changed files with 21 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "euler16"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rust-gmp = "*"
+12
View File
@@ -0,0 +1,12 @@
use gmp::mpz::Mpz;
fn main() {
let x = Mpz::from(2);
let y = x.pow(1000);
let result: u128 = y
.to_string()
.chars()
.map(|c| c.to_digit(10).unwrap() as u128)
.sum();
println!("{result}");
}