{"size": 655, "ext": "js", "max_stars_repo_path": "JavaScript/ExtendedEuclidean/extendedeuclidean.js", "max_stars_repo_name": "YOUlfey/Algorithms", "max_stars_repo_stars_event_min_datetime": "2017-02-02T18:52:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-26T18:56:50.000Z", "max_issues_repo_path": "JavaScript/ExtendedEuclidean/extendedeuclidean.js", "max_issues_repo_name": "YOUlfey/Algorithms", "max_issues_repo_issues_event_min_datetime": "2019-12-03T09:53:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-13T14:47:32.000Z", "max_forks_repo_path": "JavaScript/ExtendedEuclidean/extendedeuclidean.js", "max_forks_repo_name": "YOUlfey/Algorithms", "max_forks_repo_forks_event_min_datetime": "2019-11-26T10:04:55.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-21T09:20:47.000Z"}
{"max_stars_count": 2, "max_issues_count": 44, "max_forks_count": 4, "avg_line_length": 19.8484848485, "max_line_length": 76, "alphanum_fraction": 0.4732824427}
function extendedeuclidean(a,b)
{
    var si2 = 0, ti2 = 1, si1 = 1, ti1 = 0, qi, r, si,ti;
    while (a !== 0) {
        qi = Math.floor(b / a);
        si = si2 - si1 * qi;
        ti = ti2 - ti1 * qi;
        si2 = si1;
        ti2 = ti1;
        si1 = si;
        ti1 = ti;

        r = b % a;
        b = a;
        a = r;       
    }
    return [b,si2,ti2];
}

console.log(extendedeuclidean(3,5));


/*
    Explanation at: https://brilliant.org/wiki/extended-euclidean-algorithm/

    si2 : s(subscript(i-2))
    si1 : s(subscript(i-1))
    si  : s(subscript(i))

    ti2 : t(subscript(i-2))
    ti1 : t(subscript(i-1))
    ti  : t(subscript(i))
*/