math tricks

questions

interview questions – part 3

Question 1:

We form a 300-digit number using 100 0′s, 100 1′s and 100 2′s. Implement an algorithm to check whether the number formed is a square number or not.

Question 2:

There are two infinitely long tables. Coins are placed on one of those tables(number of coins unknown). Among those coins, 16 are placed with head facing up. The remaining are with tail facing up.

You are blindfolded and you do not know where the 16 coins are. The task is to do a particular task repeatedly such that after it is done, both the tables have the same number of coins with heads up. You can flip coins or move coins from one table to another.

Question 3:

Using two sandclocks, one which empties in 7 minutes and the other which empties in 11 minutes, how do we calculate a time interval of 15 minutes?

Solutions

VN:F [1.9.3_1094]
Rating: 1.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)

math myth – 1

  • All square numbers have odd number of factors. All other numbers have even number of factors.
  • To check whether a number is prime, it is sufficient to check its divisibiliy by all prime numbers less than square root of the number.
  • A number n is a sum of two squares if and only if all prime factors of n of the form 4m+3 have even exponent in the prime factorization of n.
  • if p is a prime number, then for any integer a, ap ? a will be evenly divisible by p. This can be expressed in the notation of modular arithmetic as follows.
    ap ? a (mod p) .  This is Fermat’s Little Theorem.
  • If an integer n is greater than 2, then the equation an + bn = cn has no solutions in non-zero integers a, b, and c. This is Fermat’s Last Theorem.
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)