• + 1 comment

    I think previousGCD should be initialize with 1 not with array[0].