• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to secondary sidebar

GoHired

Interview Questions asked in Google, Microsoft, Amazon

Join WeekEnd Online Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

  • Home
  • Best Java Books
  • Algorithm
  • Internship
  • Certificates
  • About Us
  • Contact Us
  • Privacy Policy
  • Array
  • Stack
  • Queue
  • LinkedList
  • DP
  • Strings
  • Tree
  • Mathametical
  • Puzzles
  • Graph

Find the number ABCD such that when multipled by 4 gives DCBA.

January 7, 2015 by Dhaval Dave

We need to find a number ABCD such that,  4(ABCD) = DCBA
These problems can be tricky and/or tedious, but this one isn’t too bad.Method 1 ) Forming Equations and Solving them

Start with some inequalities:

1 <= A <= 9 (since ABCD is a four-digit number, A can not be zero)
0 <= B <= 9
0 <= C <= 9
4 <= D <= 9 (D must be at least 4*A which is at least 4)

Then we have some equations:

4*D = 10*z + A (z is the carry to the tens column)
4*C + z = 10*y + B (y is the carry to the hundreds column)
4*B + y = 10*x + C (x is the carry to the thousands column)
4*A + x = D

There are more inequalities:

0 <= z <= 3
0 <= y <= 3
0 <= x <= 3 (because the multiplier is 4, the largest a carry can be
is 3)

Now we combine the first and last equations by multiplying the last by
4 and substituting for 4*D in the first equation:

4*(4*A + x) = 10*z + A   or   4*x = 10*z - 15*A = 5*(2*z - 3*A)

Since 5 divides the number on the right, 5 must divide 4*x, and
so 5 divides x.  But x is small, from 0 to 3, so x = 0 is forced. Thus

2*z - 3*A = 0, so 2*z = 3*A

Similarly, 3 divides z, so put

2*z - 3*A = 0, so 2*z = 3*A

Then

D = 8*w, and 4 <= D <= 9.

Clearly D = 8, so w = 1, A = 2, and z = 3.

Similarly, using the middle two equations, we can determine B, C, and
y. This gives
B = 1
C = 7

Hence number ABCD = 2178  and 2178*4 = 8712 

Method 2) With Logic and other Operation forming simple Equations

FINDING A

You can very quickly constrain A to equal just 1 or 2.
If A were any higher than 2, you would get 12,000 something, something, something, which violates the four digit product, DCBA.

Now, in your mind or on paper, test our multiples of 4. You quickly see that any number ending in 1 (meaning the ones digit = 1) is not divisible by 4.

Hence, you can safely say A = 2. 

FINDING D

Now, if A = 2, then D would equal 3 [3 x 4 = 12] or 8 [8 x 4 = 32] (if you wanted to include the possibility of a 1 remainder, giving you 9 for D, this is quickly ruled out, because 9 x 4 = 36, which would give you A = 6, violating your previous proof).

Now, test out your two choices for D: 3 or 8. If D = 3, you would have to solve for this equation: 4 x B + r = n3, where n3 is a two digit number with the ones place equal to 3.

This could not happen, since you have already determined A = 2. If A = 2, then A x 4 = 8. To get 3 in the one’s digit, you would have to have a remainder of 5, and 5 + 8 = 13. This would violate your 4 digit product, DCBA.

Hence you rule out 3 for D, and can equate D to 8 –> D = 8.

FINDING B

You cannot find C just yet because there are two constraints on C: the remainder from D x 4, as well as the remainder from C x 4 affecting the number for B.

So, let’s try and solve for B.

You have solved A = 2. And, you also now know that you cannot have a remainder on A, meaning that B x 4 has to equal a one digit number. This is because you have D = 8. A x 4 without remainder = D (2 x 4 = 8).

With these two constraints, you only have two numbers multiplied by 4 that will give you 1 digit products: 1 and 2. It cannot be 3 or higher, because 3 x 4 = 12, as was shown earlier.

Since each digit is not equal to the other (A cannot equal B, C, or D; B cannot equal A, C, or D; C cannot equal A, B, or D; and, D cannot equal A, B, or C), B cannot be 2, since you already set A = 2.

So, B must equal 1 –> B = 1.

FINDING C

Now that you have three of the four digits of ABCD, you can set a simple equation and solve for C.

Right now, you have 2 – 1 – C – 8, as your multiplicand. If you set up an equation for C, you get;

(4 x C) + 3 = n1

The 3 is the remainder from the multiplication of 8 x 4 = 32. You have 4 x C since you are multiplying 4 times C. And n1 is a two digit number with the one’s digit equal to 1. The reason why you know that the resultant number is two digits is because, any one digit product of any number multiplied by 4 cannot be 1. Very simple logic is needed to make that assumption.

Now, if you know the resultant number is a two digit number, and the one’s digit is equal to 1, you can easily subtract out 3 from that number.

Any two digit number with an ending digit of 1 will give you, at very minimum, 8 as your answer and at maximum any two-digit number ending in 8.

Test this theory out if you so wish: say n1 = 11, 11 – 3 = 8; say n1 = 71, 71 – 3 = 68, and so on, so forth.

With that, you can say the following:

(4 x C) = n1 – 3

–> (4 x C) = t8,

where t8 is another two digit number with the one’s place equal to 8. (We can rule out 11 as a possibility, because if n1 = 11, then C would equal 2, which would violate your proof for A = 2.)

Now, you have six possible numbers to choose from, since you already have three numbers out of 1 – 9:

3, 4, 5, 6, 7, 9

Now, out of the numbers in front of you, there is only one number that can give you a two digit number with the ending digit equal to 8.

You can employ guess and check if you so wish, but you can easily equate C to 7.

7 is the only number out of the list that gives you a two digit number with ending digit = 8.

7 x 4 = 28

So C = 7.

SOLVED PROBLEM

Now you have your unknowns:

ABCD = 2178

DCBA = 8712

Similar Articles

Filed Under: Flipkart Interview Questions, Interview Questions, Microsoft Interview Questions, problem Tagged With: Mathematical, Puzzle

Reader Interactions

Primary Sidebar

Join WeekEnd Online/Offline Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

Join WeekEnd Online/Offline Batch from 4-April-2020

WhatsApp us

Secondary Sidebar

Custom Search

  • How I cracked AMAZON
  • LeetCode
  • Adobe
  • Amazon
  • Facebook
  • Microsoft
  • Hacker Earth
  • CSE Interview

Top Rated Questions

The greedy coins game Dynamic Programming

Naurki.com Security Breach

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Find the smallest window in a string containing all characters of another string

Find the element that appears once others appears thrice

ADOBE Aptitude C Language Test

robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it

Find an index i such that Arr [i] = i in array of n distinct integers sorted in ascending order.

Reliance Jio Software Developer Interview Experience

Find if two rectangles overlap

Linked List V/S Binary Search Tree

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

Max Sum in circularly situated Values

Wrong Directions given find minimum moves so that he can reach to the destination

25 horses 5 tracks Find 3 fastest puzzle

CodeChef Code SGARDEN

Generate next palindrome number

Add Sub Multiply very large number stored as string

Singly linked list

Print Power Set of a Set

FizzBuzz Solution C C++

Best Java Book | Top Java Programming Book for Beginners

Client Server C program

Python Dictionaries

DFS (Depth First Search)

Leetcode: Merge Intervals

Flipkart SDET Interview Experience

Printing each word reverse in string

Maximum size of square sub matrix with all 1’s in a binary matrix

There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration

Copyright © 2025 · Genesis Framework · WordPress · Log in