function pgcd(nb1,nb2) { var nb3; while(nb2>0) { nb3=nb1; nb1=nb2; nb2=(nb3-nb1*Math.floor(nb3/nb1)); } return nb1; }