You are not logged in.
Pages: 1
///gcf(a, b, c, d, e, ...)
//
// Returns the greatest common factor of the arguments
// by continuing to replace the larger of the first two numbers with the remainder when dividing by the smaller until you get a remainder of 0
// once you find the gcf of the first two numbers, you find the gcf of the result and the third number, then the gcf of the result and the fourth number, etc
//
// Code by JFitch
/// GMLscripts.com/license
{
var a=argument[0];
var b;
var new_a;
var new_b;
var i;
for (i=1;i<argument_count;i++)
{
b=argument[i];
while (a!=b && a!=0 && b!=0)
{
new_a=a mod b;
new_b=b mod a;
a=new_a;
b=new_b;
}
a=max(a,b);
}
return a;
}
Offline
Pages: 1