Are you smarter than a 8th grader?

Logic Level 5

Define a sequence of natural number X ( n ) {X(n)} , where n n is any natural number, in which each digit of X ( n ) X(n) is either 0 0 or 1 1 , by the following rules:

1. X ( 1 ) = 1 1. X(1) = 1

2. 2. We define X ( n + 1 ) X(n+1) as a natural number, which can be obtained by replacing the digits of X ( n ) X(n) with 1 1 if the digit is 0 0 , and with 10 10 if the digit is 1 1 .

For example, X ( 1 ) = 1 X(1)=1 , X ( 2 ) = 10 X(2)=10 , X ( 3 ) = 101 X(3)=101 , X ( 4 ) = 10110 X(4)=10110 and so on.

A ( n ) A(n) is defined as the number of digits in X ( n ) X(n) .

B ( n ) B(n) is defined as the number of times 01 01 appears in X ( n ) X(n) .

For example, B ( 1 ) = 0 B(1)=0 , B ( 2 ) = 0 B(2)=0 , B ( 3 ) = 1 B(3)=1 , B ( 4 ) = 1 B(4)=1 , B ( 5 ) = 3 B(5)=3 and so on.

What is A ( 23 ) + B ( 23 ) A(23)+B(23) ?


Note: There have been slight edits to the original question. The original question asks for a general formula of A ( n ) A(n) and B ( n ) B(n) . Therefore, to provide for a numerical answer, the edits are necessary.

This algebra problem appears in the anime Puella Magi Madoka Magica . Students attending the Math class are just 14 years old, yet they are expected to solve the following question on the spot!

Translation credits: Puella Magi Wiki.

This problem is part of the question set Mathematics in Anime .


The answer is 64079.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Think of the zeroes as the "first" generation, and of the ones as the "later" generation, and we have the typical procedure for generating the Fibonacci sequence: every zero turns into a one, and every one remains while generating a new zero.

If we label the Fibonacci sequence as F 1 = 1 , F 2 = 1 , F 3 = 2 , F 4 = 3 , F_1 = 1, F_2 = 1, F_3 = 2, F_4 = 3, etc. then we get A ( n ) = F n + 1 . A(n) = F_{n+1}. Next, the number of zeroes in pattern X ( n ) X(n) is equal to the number of ones in pattern X ( n 1 ) X(n-1) , which in turn is equal to the number of digits in pattern X ( n 2 ) X(n-2) . Also, every zero will be followed by a one, except if the zero is placed at the end. It is easy to see that X ( n ) X(n) ends in zero precisely if n n is even. Therefore B ( n ) = { A ( n 2 ) 1 if n is even, A ( n 2 ) if n is odd. B(n) = \left\{\begin{array}{ll} A(n-2)-1 & \text{if}\ n\ \text{is even,} \\ A(n-2) & \text{if}\ n\ \text{is odd.} \end{array}\right. Thus, A ( 23 ) + B ( 23 ) = F 24 + F 22 , A(23) + B(23) = F_{24} + F_{22}, and my favorite way to calculate this is as ( 1 2 + 1 2 5 ) 24 ( 1 2 1 2 5 ) 24 + ( 1 2 + 1 2 5 ) 22 ( 1 2 1 2 5 ) 22 5 \frac{(\tfrac12+\tfrac12\sqrt5)^{24} - (\tfrac12-\tfrac12\sqrt5)^{24} + (\tfrac12+\tfrac12\sqrt5)^{22} - (\tfrac12-\tfrac12\sqrt5)^{22}}{\sqrt5} = 64079 . =\boxed{64079}.

I do it like fibo (1+2 = 3+next(0) = 4 and in the second 4+2 = 6 without next() and the third pattern is 6+4 = 10+next(0) = 11 and in the 23th iteration is 64079 and this is the ans ( but I get wrong I failed to put a digit at the end :( )

Elijah Frank - 6 months, 1 week ago
Alan Yan
Oct 5, 2015

Lol this was cool :)

Define two more recursions.

M ( t ) = Number of times 1 occurs in X(t) N ( t ) = Number of times 0 occurs in X(t) \begin{aligned} M(t) & = \text{ Number of times 1 occurs in X(t) } \\ N(t) & = \text{ Number of times 0 occurs in X(t) } \end{aligned}

For the sake of convenience, a 0 implies one 1 in the next term and a 1 implies a 10 in the next term. 0 1 1 10 0 \implies 1 \\ 1 \implies 10 Now observe that M ( x ) = N ( x 1 ) + M ( x 1 ) N ( x ) = M ( x 1 ) \begin{aligned} M(x) & = N(x-1) + M(x-1) \\ N(x) & = M(x-1) \end{aligned}

We can simplify this into N ( x ) = N ( x 1 ) + N ( x 2 ) N(x) = N(x-1) + N(x-2) with N ( 1 ) = 0 , N ( 2 ) = 1 N(1) = 0, N(2) = 1 .

Now observe that A ( x + 1 ) = 2 M ( x ) + N ( x ) = N ( x + 1 ) + N ( x + 2 ) = N ( x + 3 ) A ( 23 ) = N ( 25 ) A(x+1) = 2M(x) + N(x) = N(x+1) + N(x+2) = N(x+3) \implies A(23) = N(25) Thus we can recursively count N ( 25 ) N(25) and get that A ( 23 ) = 46368 A(23) = 46368 .

Next observe that for n n odd, B ( n ) = N ( x ) B ( 23 ) = N ( 23 ) B(n) = N(x) \implies B(23) = N(23) .

Again add recursively (or just use your old work) to get that B ( 23 ) = 17711 B(23) = 17711 .

Therefore, A ( 23 ) + B ( 23 ) = 64079 A(23) + B(23) = \boxed{64079} .

Nice solution, it captures the main essence of the problem, using recurrence relations and directly relate it to the fibonacci sequence.

However, there is a minor mistake. Shouldn't A ( x ) = 2 M ( x ) + N ( x ) A(x)=2M(x)+N(x) be A ( x ) = M ( x ) + N ( x ) A(x)=M(x)+N(x) ?

Next observe that for n n odd, B ( n ) = N ( x ) B ( 23 ) = N ( 23 ) B(n) = N(x) \implies B(23)=N(23)

This statement is true, but perhaps it can be better justified?

ZK LIn - 5 years, 8 months ago

Log in to reply

Oops, sorry that was a typo on my part. I accidentally switched M and N. And there should be a coefficient of 2 since one of them yields 2 digits.

Alan Yan - 5 years, 8 months ago

Log in to reply

The solution is correct now :)

ZK LIn - 5 years, 8 months ago

Wow. Madoka Magica the anime. I've never expected to find such things on Brilliant :)

Assume that X ( 0 ) = 0 X(0)=0 , which is perfectly fine because that leads to X ( 1 ) = 1 X(1)=1 , which is true.

Take a look at the sequence : 0 , 1 , 10 , 101 , 10110 , . . . 0, 1, 10, 101, 10110, ... , you may notice that X ( n ) X(n) is made from 2 parts, the first part is X ( n 1 ) X(n-1) and the second part is X ( n 2 ) X(n-2) . We will prove this for every positive n n larger or equal to 2 2 by mathematical induction.

Clearly X ( 2 ) = 10 X(2)=10 is made from X ( 1 ) = 1 X(1)=1 and X ( 0 ) = 0 X(0)=0 .

Suppose that X ( k ) X(k) is comprised of X ( k 1 ) X(k-1) and X ( k 2 ) X(k-2) . We will prove that X ( k + 1 ) X(k+1) is comprised of X ( k ) X(k) and X ( k 1 ) X(k-1) .

When changing the digits of X ( k ) X(k) to form X ( k + 1 ) X(k+1) , we're basically doing three tasks : Changing the digits of the X ( k 1 ) X(k-1) part, changing the digits of the X ( k 2 ) X(k-2) part and combining both parts together. By changing the digits of X ( k 1 ) X(k-1) , we obtain X ( k ) X(k) , and by changing the digits of X ( k 2 ) X(k-2) , we obtain X ( k 1 ) X(k-1) . And when combining two parts together, we are perfectly sure that X ( k + 1 ) X(k+1) is made of X ( k ) X(k) and X ( k 1 ) X(k-1) .

Hence, it is clearly that A ( n ) = A ( n 1 ) + A ( n 2 ) A(n) = A(n-1) + A(n-2) . Also, A ( 0 ) = 1 = F ( 1 ) A(0)=1=F(1) and A ( 1 ) = 1 = F ( 2 ) A(1)=1=F(2) . Hence, the general formula of A ( n ) A(n) is A ( n ) = F ( n + 1 ) A(n)=F(n+1) . Thus, A ( 23 ) = F ( 24 ) = 46368 A(23)=F(24)=\boxed{46368} .

Observe that X ( 0 ) X(0) ends with 0 0 , X ( 1 ) X(1) ends with 1 1 , X ( 2 ) X(2) ends with 0 0 and etc. Also, apart from X ( 0 ) X(0) , every number in the sequence always begins with 1 1 . It really easy to prove that 0 0 and 1 1 appear alternatively in the sequence, also to prove that every number begins with 1 1 apart from X ( 0 ) X(0) . This should be left as an exercise to the reader :)

Because X ( n ) X(n) is made of X ( n 1 ) X(n-1) and X ( n 2 ) X(n-2) , hence B ( n ) = B ( n 1 ) + B ( n + 2 ) B(n)=B(n-1)+B(n+2) for n n being an even number and B ( n ) = B ( n 1 ) + B ( n 2 ) + 1 B(n)=B(n-1)+B(n-2)+1 for n n being an odd number (we have to add 1 1 because when combining B ( n 1 ) B(n-1) and B ( n 2 ) B(n-2) , the last number of B ( n 1 ) B(n-1) , which is 0 0 , combined with the first number of B ( n 2 ) B(n-2) which is 1 1 to form another 01 01 ).

Observe that B ( 1 ) = 0 = F ( 0 ) B(1)=0=F(0) , B ( 2 ) = 0 = 1 1 = F ( 1 ) 1 B(2)=0=1-1=F(1)-1 , B ( 3 ) = 1 = F ( 2 ) B(3)=1=F(2) , we can use the above formula to find the general formula of B ( n ) B(n) , which is B ( n ) = F ( n 1 ) 1 B(n)=F(n-1)-1 for even number n and B ( n ) = F ( n 1 ) B(n)=F(n-1) for odd number n. Hence, B ( 23 ) = F ( 22 ) = 17711 B(23)=F(22)=\boxed{17711} .

Finally, A ( 23 ) + B ( 23 ) = 46368 + 17711 = 64079 A(23)+B(23)=46368+17711=\boxed{64079} .

This is really long, so just read Alan Yan's solution and enjoy :)

Nicely done. The solution is very intuitive, yet rigorous.

Your simple yet subtle observation that X ( n ) X(n) comprises X ( n 1 ) X(n-1) and X ( n 2 ) X(n-2) and the subsequent proof by induction practically solves the problem. It is a really nice crux move! :)

Glad that you have enjoyed the problem. You might also like to note that this problem is a clever reference to the anime. Note how X ( n ) X(n) is defined.

10 1 10\rightarrow1 .

In the anime timeline, the events of episode 10 10 precede episode 1 1 . Therefore, the question is suggesting that episode 10 10 is actually the first episode. Nice touch, huh? :)

ZK LIn - 5 years, 8 months ago

Log in to reply

Wow, I never thought that this question is related to the anime itself. Does this comfirm that the Illuminati is real? :)))

By the way, anime is love, anime is life.

Trung Đặng Đoàn Đức - 5 years, 8 months ago

Log in to reply

Yea, I can't stop fanboying that this math problem comes from Madoka Magica (^w^ )/

Daniel Liu - 5 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...