Because I am constantly busy working on something, I have never had time to actually put everything in words and pictures. But, since you got here, then you must have already seen some part of my work - and this is the way I’m talking.I'm 23, born in Romania, student at UPG Romania in software development field. I started from 0, mostly with basic stuff, and I’m evolving every day to an expert. I'm focused on freelancing projects, from small websites, to really heavy stuff. I know that I look and act differently from most developers, but this is why you will love to work with me!

Sunday, March 21, 2010

Find the C.M.M.D.C of an array of integers


The below method gets an array of integers and returns its C.M.M.D.C:

public int cmmdc(int[] x) {

int rest = 0;
int flag = 0;
int minim = x[0];

for (int i = 0; i < x.length; i++) {
if (x[i] < minim) {
minim = x[i];
}
}

int aux = 1;
for (int i = 2; i < minim; i++) {
flag = 0;
for (int j = 0; j < x.length; j++) {
rest = x[j] % i;
if (rest != 0) {
flag = 1;
break;
}
}
if (flag == 0) {
aux = i;
}
}
return aux;
}

No comments: