tucurruane asked on # logic problem:4 greedy brothers

There are 4 brothers who are to greedy and they have a dog and a bottle of cookies. The first brother wakes up at night and goes to the kitchen and does the next thing.

Firstly, he gives a cookie to the dog and secondly he eats the 4th part of the cookies that are left. nd he comes back to bed. After this the second brother wakes up and does the same thing, what it means that he gives one cookie to the dog and the eats the 4th part of the cookies that are left.

The third brother does the same thing and the 4th brother too. The next day when they are going to take the breakfast(the 4 brothers), first they give 1 cookie to the dog and after they divide the cookies that are left in equals parts(by 4).

The question is how many cookies there were in the bottle? I have to solve this problem by natural language, and a type of logic that is a mixture of predicate logic and mathematical logic, could somebody help me , please? Thank you

Firstly, he gives a cookie to the dog and secondly he eats the 4th part of the cookies that are left. nd he comes back to bed. After this the second brother wakes up and does the same thing, what it means that he gives one cookie to the dog and the eats the 4th part of the cookies that are left.

The third brother does the same thing and the 4th brother too. The next day when they are going to take the breakfast(the 4 brothers), first they give 1 cookie to the dog and after they divide the cookies that are left in equals parts(by 4).

The question is how many cookies there were in the bottle? I have to solve this problem by natural language, and a type of logic that is a mixture of predicate logic and mathematical logic, could somebody help me , please? Thank you

Math / Science

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a questionHansMichel

Hi again.

Last post is not correct so ignore lead to a negative answer (-1983) no negative cookies.

However this leads to

T1 = ((x - 1)/4);

T2 = ((T1 - 1)/4);

T3 = ((T2 - 1)/4);

T4 = ((T3 - 1)/4);

T5 = ((T4 - 1)/4);

4*(T5) - 5 = 0;

T1 = (1/4)*(-1 + x);

T2 = (1/4)*(-1 + (1/4)*(-1 + x))

T3 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))

T4 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

T5 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))))

4*T5 = -1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

4*T5 - 5 = -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

-6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0

Solve for x

x = 1621

There exist an x such that -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0

Hans

Last post is not correct so ignore lead to a negative answer (-1983) no negative cookies.

However this leads to

T1 = ((x - 1)/4);

T2 = ((T1 - 1)/4);

T3 = ((T2 - 1)/4);

T4 = ((T3 - 1)/4);

T5 = ((T4 - 1)/4);

4*(T5) - 5 = 0;

T1 = (1/4)*(-1 + x);

T2 = (1/4)*(-1 + (1/4)*(-1 + x))

T3 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))

T4 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

T5 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))))

4*T5 = -1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

4*T5 - 5 = -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))

-6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0

Solve for x

x = 1621

There exist an x such that -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0

Hans

ozo

If you allow negative cookies, -3 is a trivial answer,

Also, since you divide by 4 5 times, the difference between any two solutions must be a multiple of 1024

Also, since you divide by 4 5 times, the difference between any two solutions must be a multiple of 1024

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!

James Murphy

HansMichel

Hi.

This turned out to be a more interesting question than I previously thought. As for how to put this in formal logic or natural language I can't help right now. Disregard my last reply; because when I plug in 1621 back into the equations I end up with Reals or fractional parts for the brothers.

Brother 1 = 1620/4 = 405

Brother 2 = 404/4 = 101

Brother 3 = 100/5 = 25

Brother 4 = 24/4 = 6

Next Day

5/4 = 1.25 cookies for the brothers each. Nothing wrong with that except that you have fractional cookies for the brothers. Dog always gets 1.

ozo's first solution

Brother 1 1020/4 = 255

Brother 2 254/4 = 63.5

Brother 3 62.5/4 = 15.625

Brother 4 14.625/4 = 3.65625

Next Day

2.65625/4 = 0.6640625

But if you assume no negative cookies, no fractional cookies, or imaginary cookies for any one. Then the problem becomes more elagant and also interesting.

So x is 1365

1364/4 = 341

340/4 = 85

84/4 = 21

20/4 = 5

4/4 = 1

Now the sequence {0,1,5,21,85,341,1365, ...} is a very interesting sequence.

a_n = (4^n - 1)/3

If one brother got up again and gave the dog one cookie and took 1/4 the remainder then there would have been 5461 cookies.

What is interesting about this sequence is that if you represent these number is negabinary or binary they are equivalent.

{0,1,101,10101,1010101,101010101,10101010101, ...}

This problem in tems of composition of function is represented as

f(x) = ((x - 1)/4)

f(f(f(f(f(x))))) = 1.

When ever f^n(x) = 1 then x = (4^n - 1)/3.

Hans

See

http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A002450

http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A001045

http://mathworld.wolfram.com/Negabinary.html

This turned out to be a more interesting question than I previously thought. As for how to put this in formal logic or natural language I can't help right now. Disregard my last reply; because when I plug in 1621 back into the equations I end up with Reals or fractional parts for the brothers.

Brother 1 = 1620/4 = 405

Brother 2 = 404/4 = 101

Brother 3 = 100/5 = 25

Brother 4 = 24/4 = 6

Next Day

5/4 = 1.25 cookies for the brothers each. Nothing wrong with that except that you have fractional cookies for the brothers. Dog always gets 1.

ozo's first solution

Brother 1 1020/4 = 255

Brother 2 254/4 = 63.5

Brother 3 62.5/4 = 15.625

Brother 4 14.625/4 = 3.65625

Next Day

2.65625/4 = 0.6640625

But if you assume no negative cookies, no fractional cookies, or imaginary cookies for any one. Then the problem becomes more elagant and also interesting.

So x is 1365

1364/4 = 341

340/4 = 85

84/4 = 21

20/4 = 5

4/4 = 1

Now the sequence {0,1,5,21,85,341,1365, ...} is a very interesting sequence.

a_n = (4^n - 1)/3

If one brother got up again and gave the dog one cookie and took 1/4 the remainder then there would have been 5461 cookies.

What is interesting about this sequence is that if you represent these number is negabinary or binary they are equivalent.

{0,1,101,10101,1010101,101

This problem in tems of composition of function is represented as

f(x) = ((x - 1)/4)

f(f(f(f(f(x))))) = 1.

When ever f^n(x) = 1 then x = (4^n - 1)/3.

Hans

See

http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A002450

http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A001045

http://mathworld.wolfram.com/Negabinary.html

ozo

Each brother eats (n-1)/4 cookies, leaving (n-1)*3/4 cookies

HansMichel

Hi.

Yes trivial. (n -1)/4 eaten, 3(n -1)/4 left. Let (n-1) = a; a/4 eaten 3a/4 left. a/4 + 3a/4 = a(1/4 + 3/4). Also figured out where you get 1024 {0,1,5,21,85,341,1365, ...} difference between numbers.

{1,4,16,64,256,1024,4096, ...}

So x is 1365

1364/4 = 341

340/4 = 85

84/4 = 21

20/4 = 5

4/4 = 1

This sequence {0,4,20,84,1364, ...} is equivalent to (n-1)*3/4.

This sequence {0,1,5,21,85,341,1365, ...} is equivalent to (n-1)/4.

I leave it to the originator of the question to sort out which is simpler.

Hans

Yes trivial. (n -1)/4 eaten, 3(n -1)/4 left. Let (n-1) = a; a/4 eaten 3a/4 left. a/4 + 3a/4 = a(1/4 + 3/4). Also figured out where you get 1024 {0,1,5,21,85,341,1365, ...} difference between numbers.

{1,4,16,64,256,1024,4096, ...}

So x is 1365

1364/4 = 341

340/4 = 85

84/4 = 21

20/4 = 5

4/4 = 1

This sequence {0,4,20,84,1364, ...} is equivalent to (n-1)*3/4.

This sequence {0,1,5,21,85,341,1365, ...} is equivalent to (n-1)/4.

I leave it to the originator of the question to sort out which is simpler.

Hans

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

ozo

If x is 1365 then you'd get

1364 - 1364/4 = 1023 left, not 341

1364 - 1364/4 = 1023 left, not 341

Bob_Everard

Natural language(?, well as natural as possible):

The number of cookies at each stage is one more than a multiple of 4, which is the same thing as saying it's 3 LESS than a multiple of 4.

Considering one brother: when he opens the jar it contains 4*X-3 cookies. He gives a cookie to the dog, leaving 4*X-4 (easily seen to be divisible by 4). He eats a quarter of these, leaving three quarters, (3/4)*(4*X-4) = (3/4)*X - 3, which is the same form as the original number.

Let's choose a number F, which is some multiple of 4, such that the original number of cookies in the jar is F-3. After each brother has done his bit, the number of cookies in the jar must be 3^4*F/4^4 - 3. In the morning they give one to the dog, leaving 3^4*F/4^4 - 4. This is divisible by 4 if F = 4^5 (= 1024).

Brother #1 finds 1021, gives one to the dog, eats 255, leaving 765

Brother #2 finds 765, gives one to the dog, eats 191, leaving 573

Brother #3 finds 573, gives one to the dog, eats 143, leaving 429

Brother #4 finds 429, gives one to the dog, eats 107, leaving 321

In the morning, they find 321, give one to the dog, and each eat 80 cookies.

They must be pretty stupid brothers not to notice the difference between 1021 and 321.

This is a slight variation on one found earlier here involving 5 sailors, a mass of coconuts and a monkey.

The number of cookies at each stage is one more than a multiple of 4, which is the same thing as saying it's 3 LESS than a multiple of 4.

Considering one brother: when he opens the jar it contains 4*X-3 cookies. He gives a cookie to the dog, leaving 4*X-4 (easily seen to be divisible by 4). He eats a quarter of these, leaving three quarters, (3/4)*(4*X-4) = (3/4)*X - 3, which is the same form as the original number.

Let's choose a number F, which is some multiple of 4, such that the original number of cookies in the jar is F-3. After each brother has done his bit, the number of cookies in the jar must be 3^4*F/4^4 - 3. In the morning they give one to the dog, leaving 3^4*F/4^4 - 4. This is divisible by 4 if F = 4^5 (= 1024).

Brother #1 finds 1021, gives one to the dog, eats 255, leaving 765

Brother #2 finds 765, gives one to the dog, eats 191, leaving 573

Brother #3 finds 573, gives one to the dog, eats 143, leaving 429

Brother #4 finds 429, gives one to the dog, eats 107, leaving 321

In the morning, they find 321, give one to the dog, and each eat 80 cookies.

They must be pretty stupid brothers not to notice the difference between 1021 and 321.

This is a slight variation on one found earlier here involving 5 sailors, a mass of coconuts and a monkey.

PointyEars

Let's start from the "end" of the problem.

In the morning each brother eats n cookies and the dog 1. This adds up to:

4*n + 1

before breakfast. When the 4th brother entered the kitchen at night, there were therefore:

(4*n + 1)*4/3 + 1

cookies. This multiplication by 4/3 and addition of the cookie for the dog must be repeated 3 more times (one for each brother) in order to obtain N, the initial number of cookies in the jar.

This means that N is given by:

N = (n*4^5 + 4^4 + 4^3*3 + 4^2*3^2 + 4*3^3 + 3^4) / 3^4 ==>

N = (1024*n + 781)/81 ==>

N = n*1024/81 + 781/81

81 fits 9 times into 781, with a remainder of 52. Therefore:

N = n*1024/81 + 52/81 + 9 ==>

N = 4*(n*256/81 + 13/81) + 9

81 fits 3 times into 256, with a remainder of 13. Therefore:

N = 4*(3*n + (n + 1)*13/81) + 9

It is now clear that all solutions are obtained when (n+1)/81 is integer:

n = k*81 -1

The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021. The next solution is n = 161 and N = 2045...

In the morning each brother eats n cookies and the dog 1. This adds up to:

4*n + 1

before breakfast. When the 4th brother entered the kitchen at night, there were therefore:

(4*n + 1)*4/3 + 1

cookies. This multiplication by 4/3 and addition of the cookie for the dog must be repeated 3 more times (one for each brother) in order to obtain N, the initial number of cookies in the jar.

This means that N is given by:

N = (n*4^5 + 4^4 + 4^3*3 + 4^2*3^2 + 4*3^3 + 3^4) / 3^4 ==>

N = (1024*n + 781)/81 ==>

N = n*1024/81 + 781/81

81 fits 9 times into 781, with a remainder of 52. Therefore:

N = n*1024/81 + 52/81 + 9 ==>

N = 4*(n*256/81 + 13/81) + 9

81 fits 3 times into 256, with a remainder of 13. Therefore:

N = 4*(3*n + (n + 1)*13/81) + 9

It is now clear that all solutions are obtained when (n+1)/81 is integer:

n = k*81 -1

The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021. The next solution is n = 161 and N = 2045...

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!

Walt Forbes

PointyEars

Well, I find that you should also recognise those who have given an explanation for the results, like in:

N = 4*(3*n + (n + 1)*13/81) + 9

It is now clear that all solutions are obtained when (n+1)/81 is integer:

n = k*81 -1

The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021. The next solution is n = 161 and N = 2045...

Without making names... :-)

N = 4*(3*n + (n + 1)*13/81) + 9

It is now clear that all solutions are obtained when (n+1)/81 is integer:

n = k*81 -1

The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021. The next solution is n = 161 and N = 2045...

Without making names... :-)

Late but here

(1 + ((x - 1)/4) = T_1,

(1 + (T_1 - 1)/4) = T_2,

(1 + ((T_2 - 1)/4) = T_3,

(1 + ((T_3 - 1)/4) = T_4,

(1 + ((T_4 - 1)/4) = T_5 = 0.

(1 + ((x - 1)/4) = T_1,

(1 + ((1 + ((x - 1)/4) - 1)/4) = T_2,

(1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) = T_3,

(1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) = T_4,

(1 + (((1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) - 1)/4) = T_5 = 0.

There exist an x such that (1 + (((1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) - 1)/4) = 0

Hans