Skip to content

Commit 82d80e5

Browse files
committed
p69
1 parent a05b64e commit 82d80e5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/p69.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub fn run() {
2+
println!("{}", my_sqrt(2147395600));
3+
// for i in 0..15 {
4+
// println!("{i} {}", my_sqrt(i));
5+
// }
6+
}
7+
8+
pub fn my_sqrt(x: i32) -> i32 {
9+
let mut i: i64 = 0;
10+
let x: i64 = (x as i64) + 1;
11+
loop {
12+
if (i * i) >= x {
13+
return (i - 1) as i32;
14+
}
15+
i += 1;
16+
}
17+
}

0 commit comments

Comments
 (0)