For #1 a solution (n) should be a multiple of 17, since \(18^n-1=(17+1)^n-1=17k+1^n-1=17k\)
Huh? It is obvious that 18^n-1 is divisible by 17, but why would n^2 be divisible by 17?
For #1 a solution (n) should be a multiple of 17, since \(18^n-1=(17+1)^n-1=17k+1^n-1=17k\)
1. There are 3 computers. One always tells the truth, one always tell the opposite of the truth and the third one sometimes tells the truth, sometimes tells the opposite of the truth. We do not know which computer is the one that tells the truth, which is the one that tells the opposite of truth etc. We have only one opportunity to ask a question to one computer. Based on the answer, we want to pick the computer that sometimes tells the truth and sometimes doesn't. We do not need to find out which computer is the one that always tells the truth or which is the one that always tells the opposite of the truth. What question should we ask to one computer?
Here are some more interview questions:
1. Calculate \(\int_0^{\pi/6} \sec x \, dx \).
2. A bag contains 2 black socks and some white socks. One sock (black or white) is added to the bag and after that one sock is selected randomly. The selected sock happens to be black. What is the probability that the added sock was white?
3. For what values of n is \(W^n_t \) a martingale?
4. You flip a fair coin until you get "HHH"(three heads in a row).
What is the expected number of coin flips?
This is done in one line using Bayes theorem.Answers:
2. The answer is 2/5.
4. You flip a fair coin until you get "HHH"(three heads in a row).
What is the expected number of coin flips?
Well, I cannot find the smallest such number. But I can find one.1. Find least number n>17 such that \(n^2\) divides \(18^n - 1\).
So, we solved the first one. The second one has a similar solution(I suppose...),1. Find least number n>17 such that (n^2) divides (18^n - 1).
2. Find least number n>19 such that (n^2) divides (20^n - 1).
3. Find least number n>12 such that (11^n - 2) is a prime.
4. Find least number n>24 such that (23^n - 2) is a prime.
Here is a question: There is a bag with N balls numbered 1,...,N.
You pick out k balls, X_1, ..., X_k. What is the expected value of the maximum, E[max X_i, 1<=i<=k] ?
2. We buy a bag of candy. In the bag, there are 5 candies. Each candy can be one of 50 different candy types, being equally likely from each type. What is the expected number of types of candy we will have in the bag? As an example, if there are two orange candy, two apple candy and one strawberry candy in the bag, then there are 3 types of varieties.
3. X1, X2,...,Xn are independent random variables, uniformly distributed on [0,1]. What is the probability that X1+X2+...Xn<1.
Quote:
(Another interview question)
You have N cars that are all traveling the same direction on an infinitely long one-lane highway. Unfortunately, they are all going different speeds, and cannot pass each other. Eventually the cars will clump up in one or more traffic jams.
In terms of N, what is the expected number of clumps of cars?
Solution (2):
***Please see Solution (1) provided previously. It is messier and much longer.***
It is understood that although the word "jam" is used in the statement of the problem, the cars never come to a stop. What happens is that when a faster-moving car reaches a slower-moving car, then both cars move at the speed of the slower-moving car.
Note that the actual speed of the cars is immaterial to the solution; what matters is that given any two distinct cars, one of them moves slower than the other.
...
E(N) = (1)+(1/2)+(1/3)+...+(1/N).
Here is a nice and simple question:
There is a nxn square board, each square contains "-1", except that in one corner there is a "+1". On each turn you pick a row or a column and flip all signs in it. Is it possible to make all numbers +1?
Here is a nice and simple question:
There is a nxn square board, each square contains "-1", except that in one corner there is a "+1". On each turn you pick a row or a column and
flip all signs in it. Is it possible to make all numbers +1?
m-gon, n-gon, doggone it!
Inscribe a circle within a regular n-gon. Inscribe a regular m-gon within the circle. Find the ratio of the area of the regular m-gon to that of the regular n-gon.
/********* start **************/
void POLYGON_polygon(void){
print("Consider a regular n-sided polygon .....");
char file_name [40] = "c:\\exsan\\POLYGON_polygon______0000.bmp";
bool sign_this = 0;
bool display = 1;
bool save_image = 1;
bool sign_bg = 0;
bool negative = 0;
bool do_grey_scale = 0;
char * string = "POLYGON ---> polygon";
unsigned short side;
unsigned long int rows = 601;
unsigned long int cols = rows;
double x, y ;
double xx, yy, xxx, yyy;
xxx = yyy = 0;
enum {temp, page_signature, draw_page, page_alphabet};
unsigned long int pages = page_alphabet;
NETPTR net;
CELLPTR center_ptr;
center_ptr = NULL;
net = net->create_exsan_net(pages, rows, cols); // grid def
for(unsigned i = 0; i <= pages; i++)
net->set_work_sheet(i, rows, cols);
if(sign_this){
net->set_file_image(net, page_alphabet, file_name);
print("Master File: ", file_name);
}
center_ptr = net->go_to(net, draw_page, rows/2 + 1, cols/2 + 1);
double delta, eps = 0.0000000000001;
unsigned long int radius = rows / 2;
double x_f_f, x_f, x_o;
double y_f_f, y_f, y_o;
do{
net->set_page_to_data(net, draw_page, black); // reset frame
do{
print("\n [5..n] Polygon Side");
side = get_integer_pos();
if(!side){ net->delete_exsan_net(net); return;}
}while(side < 5 );
if(side > 55) side = 55; // visually makes no difference
delta = pipi/(double)side; // pipi = 2*pi
x_o = center_ptr->get_col() + radius;
y_o = center_ptr->get_row() ;
for(double theta = pipi/(double)side; theta <= pipi; theta += delta){
x_f = cos(theta); if(x_f < eps && x_f > -eps) x_f = 0; //print(x_f);
y_f = sin(theta); if(y_f < eps && y_f > -eps) y_f = 0; //print(yy);
x_f *= radius; x_f += center_ptr->get_col(); if(x_f - int(x_f) >= .5 ) x_f = int(x_f) + 1; else x_f = int(x_f);
y_f *= radius; y_f += center_ptr->get_row(); if(y_f - int(y_f) >= .5 ) y_f = int(y_f) + 1; else y_f = int(y_f);
net->draw_line(net, draw_page, x_o, y_o, x_f, y_f, 167); // 167 grey color id, external polygon
x_f_f = cos(theta + delta); if(x_f_f < eps && x_f_f > -eps) x_f_f = 0; //print(x_);
y_f_f = sin(theta + delta); if(y_f_f < eps && y_f_f > -eps) y_f_f = 0; //print(yy);
x_f_f *= radius; x_f_f += center_ptr->get_col(); if(x_f_f - int(x_f_f) >= .5 ) x_f_f = int(x_f_f) + 1; else x_f_f = int(x_f_f);
y_f_f *= radius; y_f_f += center_ptr->get_row(); if(y_f_f - int(y_f_f) >= .5 ) y_f_f = int(y_f_f) + 1; else y_f_f = int(y_f_f);
net->draw_line(net, draw_page, x_o, y_o, x_f_f, y_f_f, white); // internal polygon
x_o = x_f;
y_o = y_f;
}
net->display_image(net, draw_page, page_signature, string, file_name, sign_this, display, sign_bg, save_image, negative, do_grey_scale);
print("Another POLYGON ---> polygon");
}while(get_yes_no());
net->delete_exsan_net(net); // freeing memory
return;
}
/********* end POLYGON_polygon **************/
I did not see anybody posting the answer to this question, so I will do it.
Answer: (\frac{50^5-49^5}{50^4}\approx 4.8)
The idea is to calculate this by induction on the number of candies.
Denote P_k(m) the probability to have m varieties out of k candies
and E_k the expected number of types out of k random candies.
Suppose you already picked k candies and have m different types.
Then with probability m/50 you will still have m types after k+1 steps,
or m+1 types with probability (50-m)/50.
Hence the following equation:
(P_{k+1}(m)=\frac{m}{50}P_k(m)+\frac{50-(m-1)}{50}P_k(m-1)).
Technically, this is already enough to compute the probabilities and the expectation.
But there is a shorter way:
Write the expectation (E_{k+1}=\sum_{m=1}^{k+1}mP_{k+1}(m))
and use the formula above to reduce P_{k+1} to P_k,
after some trivial simplifications you will get
( E_{k+1}=\frac{49}{50}E_k+1 ).
Clearly E_1=1. Therefore (E_5=\frac{50^5-49^5}{50^4}).