# Finding the values of x and y using base 8 [closed]

In finding the values of x and y, if (x567) + (2yx5) = (71yx) ( all in base 8) I proceeded as under.

I assumed x=abc and y=def and followed.

  (abc+010 def+101 110+abc 111+101)=(111 001 def abc) //adding ()+()=() and equating LHS=RHS.
abc=111-010=101 which is 5 in base 8 and then def=001-101 which is -4
so x=5 and y=-4


Now the Question is that the answer mentioned in my book is x=4 and y=3.

Aaron's answer points out the problem you had. There's a general method, too. This is a simple example of a cryptarithm, where some or all the digits in an arithmetic expression are replaced by unknown variables. For addition problems, you can write each digit sum as one or more equations (since you won't necessarily know the carry values) and solve the set of equations.

For your problem, a clever solver might first check whether there's a possible pattern: could it be that the terms being added had a particularly nice forms, like perhaps

 4567
+2345
-----


Well, well, well. In octal, $4567+2345=7134$ and with $x=4, y=3$ we see that we've found a solution.

Of course, it won't always be that easy, but it's still not terrible to find the solution in this case. Given

 x567
+2yx5
-----
71yx


we could look at the 1s-place sum: $7 + 5 = x$. Aha! in octal $7+5=4$ with a 1 carry, so $x=4$. We're halfway there, with a sum that's now

 4567
+2y45
-----
71y4


Now look at the 8's column in the sum. Recalling that the 1's column gave us a carry of 1 we have $1+6+4=y$ so in octal $y=3$. We're done, modulo checking that the 64s column sum is correct, which it is.

In a true cryptarithm, often all of the numbers are unspecified, like this:

 TWO
+TW0
----
FOUR


(which does have solution(s) in octal).

I think the issue with your method is that your subtracts are neglecting to account for the carry values that happen during the addition. If we instead go right to left and account for carries, we get:

(abc+010 def+101 110+abc 111+101)=(111 001 def abc)
100
(110 + 100 + 1) // carrying the 1 here from the addition in the previous place
011
(011 + 101 + 1) // carrying a 1 from the previous place again
001
(100 + 010 + 1) // again, carrying a 1
111


Thus, we have that:

111 001 011 100 = (111 001 def abc)


Meaning that 100_2 = abc_2 and 011_2 = def_2, implying x=4 and y=3.

• I am curious to know of 001 (100 + 010 + 1) // again, carrying a 1 111 Dec 5 '14 at 19:58
• It should've been (001 + 010 +1) when following the pattern used above Dec 5 '14 at 19:59
• @tonny I'm not sure which pattern you're talking about. My apologies if the formatting is confusing. Ah, sorry, I think the pattern you're seeing is coincidental. (100 + 010 + 1) = (abc + 010 + 1) We know that abc = 100 from the result of the right-most place. On the lefthand side of the original equation, we add 010 to abc. However, we must also add 1 as a result of the addition in the previous place (011 + 101 + 1 = 1001, we must carry the leading 1 to the next place). Dec 5 '14 at 20:40