# How many diamonds? [duplicate]

A group of Seven men robbed a diamond shop at night. They ran to a nearby forest and all slept there for the night.

1. One of them woke up and tried to run away with the bag full of diamonds, but another one woke up at the same time and caught him.
2. They both decided to divide the diamonds in half and run away, but when they divided them, they got one diamond as a remainder.
3. So they woke up the third man. They again divided the diamonds and got one as a remainder.
4. They woke up the fourth, fifth, and sixth men one by one, each time dividing the diamonds equally and getting exactly one diamond as a remainder.
5. But when they woke up the last man, all the diamonds were divided equally and completely.

Since there are multiple solution for this, how many lowest possible number [greater than 0] of diamonds were there?

## marked as duplicate by Rob Watts, Deusovi♦, JonMark Perry, Mike Earnest, MariusJun 14 '16 at 6:32

• Related to this puzzle and this puzzle. – Glorfindel Jun 9 '16 at 13:44
• So those obsessive compulsive robbers were okay with running away with the loot ONLY if it was exactly divisible among them? I wonder how the first two would have felt if it turned out that the number wasn't divisible by 7 either! :) – KeyboardWielder Jun 9 '16 at 18:54

Let's say $N$ is the number of diamonds:
After the first 6 woke up we can deduce:

$N \mod 2 = N \mod 3 = ... = N \mod 6 = 1$

This means that

$N - 1$ is a multiple of the smallest common multiple of $2,3,4,5,6$.
So $N - 1$ is a multiple of 60.

After the 7th wakes up we deduce...

$N$ is a multiple of 7.

So

we need the smallest number $N$ a multiple of 7 and $N-1$ a multiple of 60.

Starting at 1...wrong because it's not a multiple of 7.
61... wrong
121...Neh
181...Nope again
241...keep looking
301...Winner.

• I think that this is better then the accepted answer, as it proves that this is the smallest possible result. – PoisonNinja Jun 9 '16 at 15:07
• Actually I should have started from 1 not 61, but it's kind of obvious the answer is not 1. – Marius Jun 9 '16 at 15:09
• @Marius: You could just edit to fix that. – user2357112 Jun 9 '16 at 16:44
• @user2357112. I did it. To be politically correct. – Marius Jun 9 '16 at 16:45
• @PoisonNinja Yes this one is the best.. – Wasiq Shahrukh Jun 10 '16 at 6:13

There are

301 Diamonds

because:

The least common multiple of 2, 3, 4, 5, 6 is 60.
So the number can be 60X+1,
We can apply from 1 to X.
x=1-> 61 ----> Wrong
x=2-> 121----> Wrong
x=3-> 181----> Wrong
x=4-> 241----> Wrong
x=5-> 301 --- Thats it!

301 %2=1
301 %3=1
301 %4=1
301 %5=1
301 %6=1
301 %7=0

• This doesn't verify that it's the smallest possible result. – eggyal Jun 9 '16 at 14:24
• @eggyal Thx for pointing out. I've included my calculations. – Kayathiri Jun 10 '16 at 3:46

There are this many diamonds:

301

Explanation in Java:

     Boolean posnumber = false;
int i = 1;
int x = 7;
while (!posnumber) {

System.out.println(i + ". " + x);
if (x % 2 == 1
&& x % 3 == 1
&& x % 4 == 1
&& x % 5 == 1
&& x % 6 == 1
&& x % 7 == 0) {

posnumber = true;

}
i++;
x = x+7;
}


Output:
1. 7
2. 14
3. 21
4. 28
(...)
41. 287
42. 294
43. 301

• you don't need code to solve this. – Marius Jun 9 '16 at 11:47
• No, but points for creativity. – Rebecca Whitlock Jun 9 '16 at 11:51
• @Marius ...yeah sure..but the Ide was open, i searched for a problem on Stackoverflow and saw this on the right under Hot Questions...well used 2 minutes to get my mind free :) – Steezar Jun 9 '16 at 12:47
• You don't need code to figure anything out theoretically. But it's cooler and at least for me, it would be the easiest way to find it correctly the first time, with minimal use of my ever lacking math talents. – discodane Jun 10 '16 at 15:23
• There is a much more concise Java answer: int i = 7; while ((i % 4 != 1) || (i % 5 != 1) || (i % 6 != 1)) { i += 7; } System.out.println(i); – user2052 Jun 10 '16 at 19:04

This type of problems is exactly what the Chinese Remainder Theorem is for.

It's used to solve systems of modular equations.

$x = 1\ mod\ 2$

$x = 1\ mod\ 3$

$...$

Where each equation $x = r\ mod\ n$ means that the remainder of $x$ divided by $n$ is $r$.

Here is an online calculator to solve it automatically.

• I think you should make the answer part more important in your answer... – AJL Jun 9 '16 at 20:24
• What do you mean? I should remove the parenthesis? – devil0150 Jun 9 '16 at 20:27
• I feel like answers are usually in a spoiler tag. That draws attention to it, usually. The explanation isn't necessarily so. – AJL Jun 10 '16 at 14:30
• Note x is unique modulus N = lcm(2, ..., 7) = 420. So 301 is indeed the lowest possible positive solution. – Oriol Jun 10 '16 at 19:43

There are this many diamonds:

2401

Explanation:

$2401\mod2 = 1$
$2401\mod3 = 1$
$2401\mod4 = 1$
$2401\mod5 = 1$
$2401\mod6 = 1$
$2401\mod7 = 0$

• you can actually get much smaller result giv it a try.. lowest possible number. – Wasiq Shahrukh Jun 9 '16 at 5:30
• @WasiqShahrukh Please edit your question and clarify the question – Inazuma Jun 9 '16 at 5:34
• Today's the first time I'm using the site. For some reason, >! ain't working – RealSalazar Jun 9 '16 at 5:35
• Not a spoiler... 'cause it's wrong. Sorry. – Malvolio Jun 9 '16 at 18:57

From the 1 left over, we have

$$N \equiv 1 \mod \mathbb{K}$$

for $\mathbb{K}$ from 2 to 6. This is equivalent to

$$N \equiv 1 \mod lcm(2,3,4,5,6)$$

or

$$N \equiv 1 \mod 60$$

or there exists a $k$ such that $60k = N-1$.

Next, we have $N \equiv 0 \mod 7$, or there exists a $u$ such that $7u = N$.

Combining equations we get $60k+1 = 7u$, or $60k \equiv -1 \mod 7$.

Now $60 \equiv 4 \mod 7$, so we get $4k \equiv -1 \mod 7$ or $k \equiv 5 \mod 7$, aka $k = 5 + 7t$.

We are then restricted by the number of diamonds being non-negative and $t$ being an integer, or $(5+7t)60+1 \geq 0$, or $7t \geq -5-1/60$, or $t \geq 0$.

Letting $t = 0$ we get $k=5$ and hence $u=43$, or 301 diamonds.

This algorithm can be followed mindlessly to generate the least number of diamonds. For example, imagine if they where short 1 each time (instead of 1 extra). Then we'd end with $4k \equiv 1 \mod 7$, or $k \equiv 2 \mod 7$ or $k = 2 +7t$ for some integer $t$. The result that $t \geq 0$ still occurs, and hence we get 119 diamonds.

Number of diamonds are:

There are 301 diamonds.

Explanation:

7y must end with 1. (since 7y-1 should be divisible by 5 and 2 at the same time; i.e, 7y-1 should be divisible by 10, or 7y must end with 1 ) hence y should end with 3 (no other digit can make 7y end with 3) 7y should be greater than 61.

Trial and Error:

7(3)<61
7(13)= 91; 90 not divisible by 60
7(23)=161; 160 not divisible by 60
7(33)=231; 230 not divisible by 60
7(43)=301; 300 divisible by 60

301

Here's how to solve it in Ruby:

(0..1000).each do |diamonds|
puts "#{diamonds}" if
diamonds % 2 == 1 and
diamonds % 3 == 1 and
diamonds % 4 == 1 and
diamonds % 5 == 1 and
diamonds % 6 == 1 and
diamonds % 7 == 0
end

• I can't get the spoiler tag to work, sorry. – Michael Fritzius Jun 10 '16 at 16:12

91

2*3*5=30
(28+2)*x+1 = N/7
(28+2)*3+1= 28*3+(6+1)=91

That's it.

• how about 4?.. it does not work for 4 – Marius Jun 9 '16 at 21:31

n+1 ,2n+1 ,3n+1---diamonds when we share these diamonds for N members evertime 1 diamond is left so lowest number is n+1

• What is n? Is it different to N? What's the value of n+1? This answer is unclear. – wizzwizz4 Jun 11 '16 at 10:22