Program to solve variations of the seven thieves & diamonds riddle
Given that this was quick and dirty program to solve a simple problem, it's understandable that some things aren't as &quot;polished&quot; as could be.  Here are some things I spotted:
gcd()
I'm guessing you copy and pasted this function because the style of the braces, the indentation, and the spacing doesn't match the rest of your code.
Overflow
When I ran your program (on a 32-bit system) I couldn't get an answer for 23 thieves because it overflowed.  Here where you compute the lcm:

       lcm = (lcm*i)/gcd(i,lcm);


you can do slightly better like this:
         lcm *= i/gcd(i,lcm);

With that change, I was able to get the answer for 23 (but not for 29).  You might want to use uint64_t instead of long to get the largest range possible (I was able to get the answer for 43 thieves using uint64_t).  Btw, that line was also indented too far for some reason.
Spacing
I personally like more spaces between things such as if(, but it's subjective.  One place that was really hard for me to read was this:

       diamonds = lcm*++i + 1;


Minor ordering change
For this line:

if(isPrime(thieves) &amp;&amp; thieves &gt; 1)


I would rather it be like this:
 if(thieves &gt; 1 &amp;&amp; isPrime(thieves))

That way you don't end up calling isPrime with some strange negative input that can have unintended consequences.