21/04/25 15:23:14.16 hSBcRYjl.net
rm(list=ls())
GCD <- function(...){
x=c(...)
sub <- function(a,b){
if (a > b) {
t = b
b = a
a = t
}
while (a > 0) {
t = b
b = a
a = t%%a
}
return(b)
}
re=sub(x[1],x[2])
for(i in 3:length(x)) re=sub(re,x[i])
return(re)
}
> GCD(1428,510,816,272)
[1] 34