Google Interview Question
Software Engineer / DevelopersEssentially that's what I answered
So the amount I have at the end of every year will be doubled...
So it forms a GP and the sum of the GP is = money of riches person
i.e. sum = 2^n - 1
so money = 2^n -1
we can calculate the n from here.
@erappy: why r u summing up the terms in GP?
After year n, the amount is 2^n. So need to find n for which 2^n is > richest person's amount, which is shown by Anand.
53B according to Forbes,
10 yrs -> 1 K
20 yrs -> 1 M
30 yrs -> 1 B
you need another 6 years to pass 56B.
that's a total of 36 years
I bet the thing they're trying to find here is if you know what 2^32 is. What I'd say in an interview is:
"Well, I don't know precisely how much money the richest guy has, but it's in the 2-digit billions.
I know 2^32 is 4.3 billion, *2 is 8.6 *2 is 17.2 *2 is 34 *2 is 68 and change, so probably circa 36.
Hey, you need 'ye' 30/36/40/42/48 whatever years to cross today's richest man. That's unfair because you never know how much wealth today's richest man can gather in the next 'ye' years.......... You cannot compare x and y, where x is present value and y is the value 'ye' years from now. Need to take the present value of y...(discounting it with risk free interest)
So, answer if you find X money after ye years, discount it by 6% for 'ye' years... That way you need few more years.....
See if this is correct
- Anand June 29, 2010Every year the amount will double.
So (log(richest person amount)base2) + 1