Untitled
raw download clone
C
views 28
,
size 523 b
#include<stdio.h>
#define max(a, b) ((a > b) ? a : b)

int GCD(int a, int b){
    if(b == 0) return a;
    return GCD(b, a%b);
}

int main(void){
    int n;
    int a[1500];
    int temp;
    int max = 0;

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n-1; i++){

        for(int j = i+1; j < n; j++){
            temp = GCD(a[i], a[j]);
            max = max(max, temp);
        }
    }
    printf("%d\n", max);
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.