Create test.rs

This commit is contained in:
Anthony Wang 2021-04-18 21:31:06 -05:00 committed by GitHub
parent 436e85c49b
commit 54129ba82f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

25
test.rs Normal file
View file

@ -0,0 +1,25 @@
fn gcd(a : i32, b : i32) -> i32 {
if b > 0 {
return gcd(b, a % b);
} else {
return a;
}
}
fn main() {
println!("Hello World");
const N: i32 = 1000;
let mut A: [i32; N as usize] = [0; N as usize];
for i in 0..N {
A[i as usize] = i;
}
let mut ans = 0;
for i in &A {
for j in &A {
ans += gcd(*i, *j);
}
}
println!("{}", ans);
}