finish 80
This commit is contained in:
@@ -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 = "*"
|
||||
@@ -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}");
|
||||
}
|
||||
Reference in New Issue
Block a user