# Math Interview Questions

interview questions shared by candidates

## Math Interview Questions

### Manager at Amazon was asked...

If you had 5,623 participants in a tournament, how many games would need to be played to determine the winner 61 AnswersBefore I could figure that out, I'd need to know whether the # of participants represents the number of individuals on larger teams, or the number of teams A specific numerical answer can be given, but there are multiple ways the tournament can be setup, for example, are there play-in games, byes, etc. I would think the question is being given to a manager to see how they think and process, and then come up with a specific numerical answer, as opposed to just a math problem. It can be just one game. A huge mock battle. Show More Responses 5,622. Assuming it is a single elimination tournament. All teams lose one game except the champs. It's always # of teams - 1 if each team plays until it loses in one(team)-on-one(team) contests, the answer is ln(5623)/ln(2) Assuming it is a simple process of elimination, it takes 5622 losers to get 1 winner from 5623 participants. So, it would require 5622 games. if it's a 1:1 type draw, then # rounds = (5623)**x where x is base 2. a good answer is between 12 and 13 rounds. 2**12 = 4096 so I'd draw up 13 rounds and give out 1,527 byes. There is no true answer as the question is very open ended. The interviewer is probably looking at task delegation, management and creativity skills. One One. Obviously. One game, all players participate. If participants equal number of teams involved, think power of 2. Show More Responses The interviewer is not looking for the right answer because there can be many. What he/she is looking for is your logical approach in solving the answer. So you could start by probing more is first I would like to understand if 5,623 participants represent the number of team or individuals. Then ask the next logical question based on the answer. Everyone who didn't ask a follow up question except Mike is right. The question says, "if YOU had ...". This requires no follow up questions, because YOU should decide how YOU are going to operate YOUR tournament. Why would Mike or any of the others think it's someone else's job to organize his/her tournament. Oh just a follow up. My tournament would be held in the top of a hardly dormant volcano. Everyone would get a backpack full of grenades and the first one out of the crater without dying wins. That makes 1 game. Also, I think most participants who got out of the volcano alive would consider themselves winners, but only one would get to keep the gold plated dancing chiquita banana. Yipee!!!! I'm right too! Take that Mike! it'd be one game if it was a battle to the DEATH I agree with Nancy there is no strict answer to this question it is all about problem solving. First thing to do is to get more information, if it is not forthcoming then make assumptions, as an interviewer I would not be impressed if the candidate didn't ask for more information, although I probably would not supply any more. Then looking for a logical (and humane) answer which is substantiated with appropriate reasoning. Ie number of people on a team, game being played, what is required to win a match, are there several games in a match? knockout style tornamant sounds like a good approach. I agree with Mike. Just show the interviewer how you think and how you will tackle the problem in a colloborative environment 1 I agree with the very first response. Many of you are perhaps making the assumption that this is a one-on-one tournament such as singles tennis. Isn't it possible the question could refer to a soccer or basketball tournament where there are multiple players on each team? That would certainly bring the number of games to be played down considerably. I'd give an approximate answer, stating my assumptions. The question asked is not the number of rounds (2 people per game: log base 2, giving approximately 13 rounds with everyone playing at least one game ) - it's the number of games. So, if two people per game, then it's the sum of 5623/2 + 5623/4 + 5623/8 + 5623/16 + ... The limit of this is not something I know off the top of my head, but it's less than 5623. Also, interestingly, you need to account for the original number being odd. That could be accommodated in a number of ways, none of them straightforward. 5622 ... if based on elimination between 2. Show More Responses I personally agree with most of you. If you read the posts here, you see all types of answers. Some say "1". Short and simple rules to a simple game. Others have posted all types of formulas and methods to figure out a process. The answers here are all a good example of different minds using different means to find an end. Those different answers are what a good interviewer would be looking for. If the job needs a person that is logical and takes time to plan things out, or perhaps someone that needs to think fast on their feet. That kind of question could come in handy for any kind of interview in my opinion. 1 I think the interviewer is asking you to ask for more information, ask three qualifieng questions to be exact in order to show you have the probing skills to fully understand a customers situation or company problem and have the ability to ask the appropriate questions to or to get the help to solve. Question 1) How many players are allowed per round? Question 2) Is there a time restriction on these rounds? (Daylight or Night as well) Question 3) Are there going to be different classes for the golfers? Are we taking handicaps into consideration? I guess there could be more questions but chances are the interviewer would stop you after the third question. The correct answer is: "I didn't come here to play bulls**t games for 8 hours, you Mac-slinging hipster. Ask me a real question." 5622....................................assuming single elimination 5623 is a prime number. Good luck dividing into even teams. Also, there is no use of the word "minimum" in the original question. This question is a good example of a problem with no absolute answer. If I were to ask this of an interview candidate (which I wouldn't because I think subjective questions are mostly a waste of time for everyone involved), I would look for someone who can: A) Ask questions to pin down a few details. B) Formulate options. C) Suggest options with recommendation and take feedback. D) Execute (pretty hard to demonstrate in the 10 minutes max I'd give this). p.s. I'd hire chapped. Good answer! Depends on the numbers of players per team. 'Excuse me, I'm just waiting for excel to open and my math wiz buddy in accounts to pick up to verify my calculation. I'll get back to you in two minutes with the answer.' I would try and be creative and put my suggestions in front of them while I give them a reason for all the options that I choose. For instance, I'd say I would create 5 levels for each game as adding more levels makes the game more challenging and interesting. I wouldn't want to set up too many games as it would require a lot of overhead using up a lot of resources for organizing large number of games. Hence, in each round I would eliminate 20 participants. That would make 100 players getting eliminated after every game. After every 10 games, I would allow all the eliminated contestants to battle it out and 15 can re-enter the game as the eliminated ones would get a chance to observe, learn, refresh and get a second chance... (The interviewer might stop me eventually before it gets too long). Even though my answer was too long, I think I would show them how my logical thinking works. They would see that I am thinking aloud and in the end all that matters is how we approach the problem rather than giving them a vague answer with no reasoning. Show More Responses Oh and I agree with Toasty, I would hire chapped :) I like the way they think. Oh and I agree with Toasty, I would hire chapped :) I like the way they think. i dont know how everybody else thinks butI divided by two with an extra game for when the number is odd and came up with 5627. the question was straight forward, " How many games".... I would have been startled as well, just reading it. Congrats on keeping your calm! My intuitive answer would have probably been: Game theory - 1 or rather none - when it's a battle to death everyone loses, even the winner (last man standing, howling at the moon). I would have likened it to the company and customer situation - in good company EVERYONE is a winner (win-win scenario). Good luck with your endeavors! 1. I think, this question is for a management position. The size of team is given as a too big random number. One cannot control a team of 5627. Divide them in a measure size, e.g size of 10 or 20 (any measureble size). With 10, there will ve 563, which can be further divided into 10, leading to apx 57. that can be futher divided into 10, leaving it to 6 teams. proformance/ goals can be set and can be evaluated later. 2. or do a marathon. None. Our PC world demands everyone gets a trophy. ********************* Keep in mind the position, Nathaniel is right. YOU are organizing the tournament, make a rational decision and describe it. Your answer should be formulated to convey a skill. For example I might suggest something like this: 1 on 1 round robin, 5,623 players, SUM(1+2+3+...+5621+5622) games Quick and simple, shows some knowledge of algorithms but not very practical. The 1st participant plays 5622 others, the 2nd plays 5621, until the 5622nd plays 1 (5623rd participant). Notice you don't add 5623. Participant with the most wins is the champion. Supposed it is a single elimination. should be 5626 games because the first row would be 5623/2 = 2811.5 which means 1 person must be going to the next round to compete therefore we will have 2812 contestants then the second row would be 2812/2 = 1406 the third row would be 1406/2 = 703(odd number which means the one of them is going to the next round without a fight. ect... I believe I would have responded with "Is that how many applicants there are for this job?" Followed by "One game, one victor." Before answering you should read the interview report this question is linked from, where the question is explained in more detail -- """If you had 5,623 participants in a tournament, and each participant had to play games until he/she one or lost, and every game had a winner and loser, how many games would have to be played in order to determine the winner of the tournament""" So it's pretty unambiguous: Participants are individuals; the tournament is single elimination; games involve just two parties (a winner and a loser.) The question doesn't ask about the number of rounds involved, nor about timeframe. Just the sheer number of games. So we're left with an answer of 5622 games (because every game has one and only one loser and 5623 - 1 participants need to lose for there to be a single participant left as the winner, so that's how many games there must be.) Show More Responses Assuming in each game "n" people participate and there is just one winner in a game. If N is the total number of people (in this case 5623), then the approximate number of games would be: log(N)/log(g) -1 After each round, you would have half the number that started the previous round; except if it were an odd number it would he half + 1. So 13 rounds. 2812 1 1406 2 703 3 352 4 176 5 88 6 44 7 22 8 11 9 6 10 3 11 2 12 1 13 It is far simpler than you guys are making it out to be. In ALL single elimination tournaments there is one less game than the number of participants. Because in every game 1 team gets eliminated. And at the end 1 team has to be left standing. This will be a detailed explanation. Since they're asking for a tournament, that means one on one matches, and eliminations of 'participants' or players. With such a large number doing a round robin style tournament would not be very efficient, as every player would have to play every other player, ((N-1)^2)/2 =15,803,442 matches. I would first start to get more details of the tournament. If it were up to me to design the tournament and easily determine the number of matches, I would go with single elimination bracket because since its based on power of 2. Contrary to what what Bob InNorCal did, you dont start halving the at the beginning with 5623, because its not power of 2. You will get to a point where there wont be even numbers, and BYEs will have to be given, it would be unfair to give byes out at the end or middle of the tournament, players would complain that others got BYEs and they didnt. Detailed Explaination: In a single elimination bracket, the brackets end with 1 match between 2 players, then 2 matches and 4 player, and eventually for this tournament, 4096 matches between 8192 players. But since we dont have 8192 players, there will have to be BYEs which wont count as matches. In this case we'll have to use a 8192 single bracket, with the first 4096 players spread every other position then the last 1527 players spread evenly throughout the bracket and the remaining 2569 positions are BYEs (4096 + 1527 + 2569 = 8192). Here are how the rounds look like: A - 1527 matches, (4096 matches was suppose to happen, but 2569 BYEs are no counted) B - 2048 matches, C - 1024 matches, D - 512 matches, E - 256 matches, F - 128 matches, G - 64 matches, H - 32 matches, I - 16 matches, J - 8 matches, K - 4 matches L - 2 matches, M - 1 match From round B-M, its (2^12)-1 = 4095, so with Round A, its 4095+1527=5622. The calculated answer 5622 is one match less than the number of participants. However, just because its easy with single elimination to determine the number of matches, does not mean that it is what they initially asked, conversing with the interviewer for more details of the tournament is important. If the interviewer said it was a double elimination tournament then a player would have to lose twice in the bracket to be eliminated from the tournament. Depending on the number of players and the placement of the BYEs, then calculating the number of matches in a true double elimination maybe difficult. Also in Double Elimination, the winner maybe won by someone without a loss or with 1 loss, the winner without a loss means one less game. it is assumed that the competition is a head to head knockout competition like wimbledon. the only correct answer is 5,622. the quickest and smartest way to get that answer is to see that in a knockout tournament every body loses once and only once, except the winner. in every match, one person loses. therefore the number of matches required equals the number of players minus 1. PaulO, Jordan, madhur, simplebrain and key2success you are all hired! How many games are played? Well all of them of course, how else do you find the winner. It need only one game to find the winner If it is your game you can appoint a winner without playing any games. Then 0 is a possible answer. 1 is also a viable answer, if it is a game of life and death it is possible that no one lives then there are no winners on the first round. Such as a game that on the first round were everybody is exposed to a nuclear blast. Even those exposed to the fall out might be considered losers. A game like chess where you eliminate draw contestant then 1 round to 13 rounds would be required. You could divide by 2 to get the rounds or use logarithms to convert 2**13 which is greater than 5,623 to a log equation such as log(5,623)/log(2). Potentially everybody can loose on the first round because of the draw rule and the person with the bye on the first round can loose because they have no one to play to win. You can change the rules so that infinite rounds are required to determine a winner. One way to do this is to increase the elimination rounds so that it approaches infinity. As this goes on your interviewers glaze over and fall to sleep and when they wake up they decide not to give you the job. This can be poker tournament (as too many players). From 5-7 people - one wins. This can keep number of games to reasonable limit. Depends on how many rounds there are to determine a winner. Logical answer here could be 5623 Show More Responses 5,623 - each person plays, person with the highest score wins. There would be 5613 head-to-head games cosisting of 12 rounds with one team receiving a bye in each round except the fourth round, the tenth round, and, of course, the twelfth round. Assuming the tournament is Mortal Kombat everyone knows that earth realm has to win because out realm is evil and evil... Sucks. No games necessary. What kind of tournament? There will be 2 games. The first game is a question: Would you like to play a game? Which is then followed by the second game - one involving thrones. One 2 The simple answer is Number of Teams minus ONE. Simplified, a four team bracket plays 3 games. |

### Trader at Jane Street was asked...

What is the sum of the digits of all the numbers from 1 to 1000000? This is different from the sum of the numbers. For instance the sum of the numbers from 1 to 10 is 55 whereas the sum of the digits is 46. 16 AnswersThe main idea is that if you write all the numbers from 0 to 999999 down as six digit numbers (possibly prepending zeros) then all digits appear the same number of times. So, its digit appears exactly 6 x 1000000/10 = 600000 times. so the result is 600000x 45 +1 (+1 for the number 1000000) Maybe I'm reading it wrong, but isn't the sum of the digits of 1-10 just 11? 1 digit for 1-9, 2 digits for 10-99? So it's 9+90*2+900*3+9000*4+90000*5+900000+6 no, I think the easy way to solve it in your head is to remember that when adding all digits 1 to 100, you have 50 pairs: 1+100, 2+99, etc. Each pair is 101, times 50 is 5050. 1 to 1000 would be 500500 so 1 to 1,000,000 would be 500,000,500,000 Pretty cool, huh? Show More Responses scott, dude you should add digits not the numbers, so 99+2 = 18+2 =20. not 101 Scott's answer from May 24 is the correct way to think about it if summing the numbers. The answer is 27,000,001 - if you do it programatically the operation is a simple map reduce - simply map a digit sum function across the list of values [1, 1000000] and then reduce an addition operator across the result. Python Proof: >>> sum(map(lambda n: sum(map(int, str(n))), xrange(1, 1000001))) 27000001 21085156 Don't mind the above answer. I read the question wrong. Each digit will appear 1+10+100+1000+10000+100000 times. so the answer is 111,111*45+1=4444440+555555+1=4999996 nb is right. Another way you can think about it easily is if you want the digits from 1 to 1,000,000 then each digit should appear 1/10 * 1,000,000 times. So 100,000 x 6 (for each place value) x 45 (the sum from 1 to 9) + 1 (for the 1 million) 27,000,001 I think John Doe is right. 27,000,001 is what I got. Think of each number as a 6 digit number. The average number each digit could be from 000,000 to 999,999 is (9+0)/2=4.5. Since the average of each number is 4.5 and there are 6 digits the average sum of the digits for a 6 digit number should be 4.5*6=27. There are 1 million numbers from 000,000 to 999,999 so the sum of the digits from 000,000 to 999,999 is 27,000,000. Subtract the digits of 000,000 which is just 0 and add the digits of 1,000,000 which is just 1 to get 27,000,001. For arbitrary a=1,...,9 accounts the how many a's appear in the six digit number. 1 * C(6,1)*9^5 + 2* C(6,2)*9^4 + 3 * C(6,3) * 9^3 + 4*C(6,4)*9^2 + 5*C(6,5)*9 +6*C(6,6) = 600000. 600000*(1+2+3+...+9)= 27000000. Then add the 1 from 1000000. The ans is 27000000. Show More Responses 2.7 x 10^7 + 1 general rule: to 10^n answer is 10^n * n * 4.5+1 here n=6, result is 27 000 001 1-1000000 same as sum of digits in 0 - 999999 then plus 1, treat 0 - 999999 as a 6 digit random number, then the digit of sum is sum of digit for each number: 1000000*(4.5*6)=27000000, so answer is 27000001. |

Implement a power function to raise a double to an int power, including negative powers. 11 AnswersCould be implemented many ways. I got the feeling that the interviewer wanted to see you approach the problem in multiple ways and demonstrate confidence in your math and recursive skills. #include #include #define MAX_ARRAY_LENGTH 256 double power(double, unsigned int); int main(int argc, char** argv) { double a = atof(argv[1]); int b = atoi(argv[2]); double result = power(a, b >> 31 == 0 ? b : -b); if ((unsigned int) b >> 31 == 1) { result = 1 / result; } printf("%f\n", result); return 0; } double power(double a, unsigned int b) { switch (b) { case 0: return 1.0; case 1: return a; default: return (b & 1) == 0 ? power(a * a, b >> 1) : power(a * a, b >> 1) * a; } } c implementation of the above (no recursion): int ipow(int base, int exp){ int result = 1; while(exp){ if(exp & 1) { result *= exp; } exp >>= 1; base *= base; } return result; } Show More Responses int power(double n, int exp) { bool npower = (exp < 0) ? true : false; double result = 1; exp = abs(exp); // get the absolute value for (int i = 0; i < exp; i++) { if (npower) { result = result/n; } else { result = result*n; } } return result; } C# code verified: static double Power(double d, int exp) { if (d == 0 || exp == 0) { if (exp >= 0) { return 1; } else { return double.PositiveInfinity; } } int expAbs = Math.Abs(exp); double res = d; for (int i = 1; i 0) ? (res) : (1 / res); } double power(double x, int y) { if(y == 0) return 1; int sign = 1; if(y < 0) sign = -1; y = abs(y); double d = power(x, y/2); if(y%2 == 0) d = d*d; else d = x*d*d; if(sign == -1) return 1.0/d; else return d; } I am surprised that not a single person here had noticed that the guy asked to raise a DOUBLE to a given power. Men, double are not integers. Their exponent is stored in a part of their binary representation. If you multiply n times a double you will make n times a rounding error and n useless calculations. Just changed the binary part of the double that is related to its exponent, and here it is, your double has been raised to a given power, a you absolutely lost no precision, and you've made 0 calculations. This is basic stuff, every university teaches that to its students... floating numbers representation... I believe interviewer is expecting for this public static double Power(double x, int y) { double result = 1; bool isNegative = y 0) { if ((y & 1) > 0) { result *= x; } y = (y >> 1); x *= x; } if (isNegative) result = 1 / result; return result; } Verified C# static double Pow(double b, double exp) { if (exp == 0) return 1; else if (exp > 0) return b * Pow(b, exp - 1); else return 1 / Pow(b, -exp); } Does it get more compact? TD's answer is interesting, but not very useful. If you actually try it you'll find that since the double's base is 2, any changes to the exponent portion approximately multiply (or divide) numbers by a power of two. I say approximately here, since TD forgot to mention that the number itself isn't stored in float point numbers, only the digits after the implied 1. So yes, it's important to know how floating point numbers work, but modifying the exponent portion of a floating point number is a fundamentally incorrect solution. public double power(double num, int exp) { if(exp == 0) return 1; double res = 1; for(int e=Math.abs(exp);e>0;num*=num,e>>=1) { if( (e&1) == 1) res *= num; } return (exp>0)?res:1.0/res; } |

### Summer Intern at Five Rings Capital was asked...

• Is 1027 a prime number? • How would you write an algorithm that identifies prime numbers? • 2 blue and 2 red balls, in a box, no replacing. Guess the color of the ball, you receive a dollar if you are correct. What is the dollar amount you would pay to play this game? 6 AnswersAn algorithm for testing prime numbers is trial testing, test whether whether the number is dividable by an integer from 2 to its square root. For the color guessing game, the expected number of dollars you get is the average identity between a permutation of rrbb and rrbb, which is 2. For the prime number testing, only the number 2 and then odd numbers need to be tested. If it is not divisible by 2, there is no need to test against any other even number. So start with 2, then 3, then increment by 2 after that (3,7,9,...) until you are greater than the square root (then it's prime), or you find a divisible factor (it is not prime). To test for divisibility, we are looking for a remainder of zero - use a MOD function if available. Taking the integer portion of the quotient and subtracting from the actual quotient: if the difference is zero, then the remainder is zero and we have a divisible factor. If the difference is nonzero, then it is not divisible and continue testing. In this case, we find that dividing by 13 gives 79 with no remainder, so it is not prime. For the guessing game, the minimum winnings are $2 every time with the proper strategy. I'm assuming the rules are you pay to play and you get to guess until there are no more marbles. Say you guess wrong the first attempt. (you guess blue and it was red). So now you know there are 2 blue, 1 red. Your logical choice is to choose blue again, since there are more of them. But say you guess wrong again. Now you know there are 2 blue left, so you will win on both of the last 2 draws. If you were correct on one or both of the first two trials, then you could wind up with an even chance on the third trial, so you would win that some of the time, then you'll always win on the last trial. Show More Responses David, I think we could pay more that $2 and still come out on top. You logic seems sound, but looking at the probabilities I see: 1/2+1/3*(2)+2/3*(5/2) = 17/6 = ~2.83 Choosing the first ball, we obviously have an expected value of 1/2. Then, WLOG, we are left with RRB. Clearly we then choose R as this gives us a 2/3 shot at picking correctly. If it is R, then we get that $1, have a 50% shot at the next, and are assured the last, giving us, on average, $2.5. If it is B, then we know the next two will be R, giving us $2. As you can see, with an optimal strategy, we should expect to make ~$2.83 per round. Take the square root fo 1027. You get 32.04. Need only to check if divisible by prime numbers from 1 to 32, which include 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31 For algorithm, see Lucas' test on Wikipedia, where there is also pseudocode. 1027 = 1000 + 27 = 10^3 + 3^3 and you know you can factor a^3 + b^3 |

### Summer Analyst at Goldman Sachs was asked...

13 cubed 6 Answers2197 how long did it take you to answer this? I assume thats what they were testing I did it while doing some chit chat about his day. No longer then two minutes, and then he asked how I did it. So I explained the steps. Show More Responses really easy on paper, in your head, not so easy. In your head, here's how I'd do it: 13 squared is 169- that's easy. then, 10 times 19 is 1690, and 3 times 169 is approx 500, so 2190 is an easy approximation. Only 7 off from the actual answer! 13*13 = 169. Then do 13*170 = 10 * 170 + 3 * 170 = 1700 + 510 = 2210 Then, 2210 - 13 = 2197 Do it on your head. 13*13 = 169. For 169*13 first 3*169 = 507 second 10*169 = 1690 Finally 169*13 = 507 + 1690 = 2197. |

One thousand 1x1x1 cubes in a 10x10x10 cube. Outside spray painted. How many have no paint.\? 5 Answers1000-8^3=488 Its asking how many have no paint, so its just 512 1000....because they are placed INSIDE the 10x10x10 cube, thus the only cube getting painted is the big one. Show More Responses 1000- the number of cubes on the outside = 1000 - 2 sides - 2 other sides (not counting the cubes that were already counted by the 2 previous sides) - 2 remaining sides (not counting the cubes that were counted by the 4 previous sides) = 1000 - 200 - 160 - 128 = 512 or just count the number of cubes on the inside = 8^3 = 512 http://brainteaserbible.com/interview-brainteaser-cube-dipped-in-paint-10x10x10 |

If you have a three gallon jug and a five gallon jug No marks on either one The goal is to fill the five gallon jug with four gallons of water How is this accomplished? 5 AnswersTake 5 gal. and pour into the 3 gal. The 5 now has 2 gal. Empty the 3 gal, and pour the remaining 2 gal into the 3 gal. Fill the 5 gallon and pour 1 gal. (which is the remainder of the space in the 3 gal.) This gives you 4 gal. that was from die hard 3. 1) fill up the 3 and pour it into the 5. 2) fill up the 3 and fill up the rest of the 5. that leaves 1 in the three. 3) dump out the 5. 4) pour the 1 that's left in the three into the 5. 5) fill up the 3 again and pour it into the 5. see - easy peasy. might be a bit rougher if solving it is necessary to stop a bomb from blowing up the city. mclain and samuel L got it done. 1) Fill up half of 5 gal (2.5 gal) from 3 gal jug 2) Fill up half of 3gals jug(1.5 gal) and pour into 5gal jug 2.5 + 1.5 = 4gal Show More Responses Die Hard 2 also has the solution to this question. there are actually 4 die hards, which is why you two are confused. 1. the classic big LA building he runs through glass 2. the airport based one 2*. the new york fed gold gets stolen (die hard with vengence) -- THIS is the one with the water puzzle. 3. the newest die hard where the stop lights get taken over etc, live free die hard i think |

### Analyst at Fidelity Investments was asked...

You sell 200 cups of coffee per year at $10 for a cup. It costs you eight dollars to produce a cup of coffee. Would you rather double your price but loose half of the amount you sell or keep the price the same and double the amount that you sell? Which is more realistically feasible? 5 AnswersIf you double your volume, while keeping the price constant, you make $800 (($10-$8)($400)) and if you double your price but loose half of your volume you make $1,200 (($20-$8)(100)). The catch is, however, that it is much easier to do the former because no one would realistically buy your good if you double the price. I don't agree with the part that practically it is easier to double the quantity while keeping the price same. Neither do I agree with the other side. I'd ask for more data, ask more questions before I answer that viz. if we know consumer's willingness to pay, price of substitutes available, what would it take to double the quantity sold at the same price, demand curve etc. either way, it's "Lose" not "loose" so if it was a written test, don't write "Loose" Show More Responses It is definitely easier to sell half as much volume. Your sales volume remains the same, while your costs are lower AND - It is less work. To double the volume requires more work. Since they tell you what happens to price and volume you don't have to guess at elasticity or substitutes. But its not as easy as just adjusting revenue and volume because you have a utliziation component. Selling coffee has a high fixed cost, ie rent and labor. Whether you sell 1 cup or 1000 cups, you still need the store and an employee and so your profit will vary widely. So my first question would be to ask if the cost stays the same. If yes, then just do math above but then this wouldn't be a challenging question. As for which is feasible, since elasticity is 1 in both cases, they are both feasible. However, since these are not likely real world outcomes, I would ask more questions which I'm guessing is exactly what this question is designed to do. |

### Web Development Engineer at Amazon was asked...

How would you implement integer division if your language did not offer it. 5 Answershttp://www.bearcave.com/software/divide.htm #Assumes positive numbers def divide(num, divide_by) answer = 0 return answer if divide_by == 0 while(num >= divide_by) num = num - divide_by answer = answer + 1 end answer end puts divide(10,0) I think this is all you need, as the question asks for integer division I.e. 2 integer inputs to provide integer output 3 / 4 = 0 (dividend is less than the divisor) 2 / 1 = 2 (divisor is 1) 4 / 2 = 2 (divisor is a factor) 7 / 5 = 1 (dividend is greater than divisor) Note: solution below is for positive integers public static double divide(int dividend, int divisor) { int remainder = dividend; int count = 0; while (remainder > divisor) { remainder -= divisor; count++; } return count; } Show More Responses EDIT: To also handle divide by zero and negative numbers public static int divide(int dividend, int divisor) throws ArithmeticException{ int remainder = dividend; int count = 0; if (divisor == 0) { throw new ArithmeticException("Divide by 0"); } if (remainder > 0 && divisor = divisor) { remainder -= divisor; count--; } } else if (remainder 0) { remainder *= -1; while (remainder >= divisor) { remainder -= divisor; count--; } } else if (remainder = divisor) { remainder -= divisor; count++; } } else { while (remainder >= divisor) { remainder -= divisor; count++; } } return count; } Simpler version (assuming you are allowed to use multiplication), just compute the sign at the end and multiply: function divide(a, b){ if(b == 0) throw "Cannot divide by zero"; var remainder = Math.abs(a); var dividend = Math.abs(b); var result = 0; while(remainder >= dividend){ result++; remainder -= dividend; } if(result > 0 && a*b < 0) result *= -1; return result; } |

We have a pond containing a single bacterium. The number of bacteria double every 5 minutes, and the pond is full of them in 24 hours. If we started with the same pond but two bacteria, how long will it take to fill the pond? 4 AnswersI struggled with this a bit and got close. I believe answer is: 23:55 This is a clear case of Geometric progression. Find the nth term Tn1 = a*r^(n-1). where n = (24 * 60)/5,a = 1 and r=2. when the initial value (a) = 2, the values become n = ?, a = 2 and r = 2. Since Tn1 = Tn2, Equate the RHS of both the equation. Since the base are equal, equate the powers, doing so will give the n value. When n is convert into minutes one get 23 hrs 55 minutes. this is easy, you don't need all the math. The pond was half full five minutes before, so it's 23:55 Show More Responses The first pond started with 1 bacterium and doubled to 2 in five minutes. Therefore, the second pond will take 5 minutes less than the first to be full. ie: 23:55 |