finish 80

This commit is contained in:
Dr. Matthias Ratajczak
2022-08-19 20:44:19 +02:00
parent 6fd36005fc
commit 2f6c1ef96b
2 changed files with 31 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "euler80"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rug = "*"
+22
View File
@@ -0,0 +1,22 @@
extern crate rug;
use rug::Float;
fn main() {
let mut result = 0;
for x in 2..=100 {
let two = Float::with_val(1024, x);
let root = two.sqrt();
let inner: u32 = root
.to_string()
.chars()
.filter(|c| *c != '.')
.take(100)
.map(|c| c.to_digit(10).unwrap())
.sum();
if inner > 50 {
result += inner;
}
}
println!("{result}");
}