Serving the Quantitative Finance Community

 
User avatar
billypilgrim
Topic Author
Posts: 0
Joined: September 3rd, 2014, 1:08 pm

My first serious post

January 1st, 2015, 2:28 pm

Bought a copy of Dan Stefanica's quant interview book. Found this question (e^(pi) ) in that collection.Another interesting numbers question in the collection (if anyone cares to try)-2^29 has nine different digits. Which is the missing one?
 
User avatar
bluetrin
Posts: 2
Joined: September 9th, 2005, 6:41 am

My first serious post

January 9th, 2015, 9:16 am

QuoteOriginally posted by: billypilgrim2^29 has nine different digits. Which is the missing one?Can you give a clue ? I am far from being as good as the other people in this thread
 
User avatar
billypilgrim
Topic Author
Posts: 0
Joined: September 3rd, 2014, 1:08 pm

My first serious post

January 11th, 2015, 12:05 am

QuoteOriginally posted by: bluetrinQuoteOriginally posted by: billypilgrim2^29 has nine different digits. Which is the missing one?Can you give a clue ? I am far from being as good as the other people in this thread I have seen the solution, but haven't done it myself. The solution uses the fact that the difference between a number and the sum of it's digits is always divisible by 9. But looking at the solution, it's not something I can think of in an interview. May be someone else has a better method. I was guessing 7 since 7 doesn't appear till as far as 2^13, but that's not the correct answer.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

My first serious post

January 11th, 2015, 9:28 am

QuoteOriginally posted by: billypilgrimQuoteOriginally posted by: bluetrinQuoteOriginally posted by: billypilgrim2^29 has nine different digits. Which is the missing one?Can you give a clue ? I am far from being as good as the other people in this thread I have seen the solution, but haven't done it myself. The solution uses the fact that the difference between a number and the sum of it's digits is always divisible by 9. But looking at the solution, it's not something I can think of in an interview. May be someone else has a better method. I was guessing 7 since 7 doesn't appear till as far as 2^13, but that's not the correct answer.That description of the solution obscures it. Another way to put it is mod(x,9) = mod(sum_of_digits(x),9) and, by the distributive property of arithmetic, mod(c*x,9) = mod(2*mod(x,9),9)The pattern for mod(2^i,9) for i = 1 to 29 is: 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5. The sum of digits 0 through 9 is 36, mod(36,9) = 0 which is what the answer would be if 2^29 had one copy each of all ten digits. The only way to get mod(sum_of_digits(2^29),9) = 5 using all but one of the digits is if the "4" is missing.A quick check on a pocket calculator shows 2^29 = 536870912, verifying the result.
 
User avatar
billypilgrim
Topic Author
Posts: 0
Joined: September 3rd, 2014, 1:08 pm

My first serious post

January 11th, 2015, 12:42 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: billypilgrimQuoteOriginally posted by: bluetrinQuoteOriginally posted by: billypilgrim2^29 has nine different digits. Which is the missing one?Can you give a clue ? I am far from being as good as the other people in this thread I have seen the solution, but haven't done it myself. The solution uses the fact that the difference between a number and the sum of it's digits is always divisible by 9. But looking at the solution, it's not something I can think of in an interview. May be someone else has a better method. I was guessing 7 since 7 doesn't appear till as far as 2^13, but that's not the correct answer.That description of the solution obscures it. Another way to put it is mod(x,9) = mod(sum_of_digits(x),9) and, by the distributive property of arithmetic, mod(c*x,9) = mod(2*mod(x,9),9)The pattern for mod(2^i,9) for i = 1 to 29 is: 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5,1, 2,4,8,7,5. The sum of digits 0 through 9 is 36, mod(36,9) = 0 which is what the answer would be if 2^29 had one copy each of all ten digits. The only way to get mod(sum_of_digits(2^29),9) = 5 using all but one of the digits is if the "4" is missing.A quick check on a pocket calculator shows 2^29 = 536870912, verifying the result.Cool. This seems better. Thanks.
Last edited by billypilgrim on January 10th, 2015, 11:00 pm, edited 1 time in total.