Friday, February 25, 2011

Number, Reminder & Mystery

There is a number N

If N is divided by 7 the remainder is 1, it can be shown as mod operator.

N%7=1

N%9=2

N%11=3

What is N?


the way to find the answer is the trail and error method. for that start with the 7 .check the 7+1 =8, 7*7+1=50, and 7*7*7+1=344. check the number 344 with 9 and 11 it gives the remainders 2 and 3 respectively. so 344 is the one of the required number . to calculate the remaining numbers the formula is lcm(7,9,11)*any real number + 344.
so the answer is the numbers 693*x+344. where x=0,1,2,……

BBoxes & N Dollers

“You have b boxes and n dollars. If I want any amount of money from 0 to n dollars, you must be able to hand me 0 to b boxes so that I get exactly what I request.” The two questions were “What are the restrictions on b and n, and how is money distributed among the boxes?”



The trick is of Binary Numbers
2^0=1
2^1=2
2^2=4
2^3=8
2^4=16
….


2^7=128


..

The formula is [log n to base 2] + 1 = b e.g b=logn+1 with base 2
where [] denote integral part of the log base 2 of n

Example
So if we want 0 to 15 dollars
[log of 15 to base 2] + 1 = [3.90] + 1 = 3 + 1 = 4 boxes
we need to have 4 boxes each having 1,2,4,8, dollars respectively.Now we know from binary numbers that any amount from 0 to 15 can be formed with this boxes.

For 0 to 6 dollars
[log of 7 to base 2] + 1 = [2.58] + 1 = 2 + 1 = 3 boxes
we need to have 3 boxes each having 1,2,4, dollars respectively

For 0 to 100 dollars
[log of 100 to base 2] + 1 = [6.64] + 1 = 6 + 1 = 7 boxes
we need to have 7 boxes each having 1,2,4,8,16,32,64 dollars respectively

Correct me if Anything wrong