aboutsummaryrefslogtreecommitdiff
path: root/test.rs
blob: da6a93380959254dd7d8c08a1af3ff61ef8c6adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Rust

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);
}