Firstly, your implementation is (arguably) not quite correct:

 else if((m &lt; 0) || (n &lt; 0))
     return -1;


The GCD of two negative numbers is perfectly well defined. However, if you really don't want the user to pass in negative numbers, make it explicit in the function signature:

unsigned greatestCommonDivisor(unsigned m, unsigned n)


Euclid's algorithm is one of the most basic examples of where recursion shines:

unsigned greatestCommonDivisor(unsigned m, unsigned n)
{
    if(n == 0) return m;
    return greatestCommonDivisor(n, m % n);
}


We first check the base case, which is 2: If r is 0, n is the answer; if r is not 0, continue to step 3. The recursive call actually combines steps 1 and 3 here: m % n sets n to be the remainder r, and we call the function again with n = m.

As a final note, a lot of people avoid recursive functions in C/C++ because most compilers don't optimise tail-calls to use constant stack space. However, Euclid's algorithm will perform only O(log N) steps, hence it's easy to see on any computer with (reasonable) stack size, this won't cause a stack overflow for numbers whose size is constrained by int or unsigned.

Euclid's Algorithm (Greatest Common Divisor)
I have one HP ML370 G5 server. Which has four 146GB SAS disks and two 300GB SAS disks that are configured as RAID 0.
I have encountered a problem with one of my disks. The windows server event viewer shows the error below:


  Logical drive 2 configured on array controller P400 located in server
  slot 1 returned a fatal error during a read/write request from/to the
  volume. Logical block address 6331648, block count 256 and command 32
  were taken from the failed logical I/O request. Array controller P400
  located in server slot 1 is also reporting that the last physical
  drive to report a fatal error condition (associated with this logical
  request), is located on bus 0 and ID 1.


How can I determine whether all of my disks work well or not? and check for bad blocks on my disks!
