remainder = function(a, b){

quotient = floor(a/b)

remainder = a - b*quotient

return(remainder)

}

euclid = function(a,b){

while (min(a,b) != 0) {

if (a > b){

a = remainder(a,b)

} else{

b = remainder(a,b)

}

}

return(max(a,b))

}

Im trying to create a function to find the greatest common divisor. can anyone see where i have gone wrong?