write an algorithm to divide two numbers using only loops and addition.
Respostas da entrevista
Sigiloso
12 de mai. de 2010
delegate the problem to one of the mindless google calculator boys.
1
Sigiloso
3 de jun. de 2010
I'm not sure a correct answer for this question is going to say, "Hey...Here's the next designer/programmer of Chrome v2"....? WTF?!?
public static void main(String[] args){
int divisor = 2;
int number = 100;
int i = Integer.MAX_VALUE;
for (int j = 1; j = number) {
System.out.println((j));
break;
}
}
}
1
Sigiloso
10 de jun. de 2010
If they were looking for engineers with dumb ideas like totally destroy their branding by copying Bing's background image function, this would definitely be a good recruiting questions.... like I said before; idiots!
Sigiloso
7 de jul. de 2010
int a = 9;
int b = 2;
int sum = 0;
int result = 0;
while (sum + b < a) {
int term = b;
int mult = 1;
while (sum + term < a) {
result = result + mult;
sum = sum + term;
term = term + term;
mult = mult + mult;
}
}
Print result;
It's not hard to realize the calculation time is O(Log(a)) and more precisely C * Log(a/b) <= Time <= C * 2 * Log(a/(2*b))
Sigiloso
17 de mai. de 2010
// I don't get this question....
// Is there any Aha algorithm for solving it, instead of the naive approach?
int divide(int dividend, int divisor)
int ans=0, partial=0;
while(partial+divisor
Sigiloso
17 de mai. de 2010
No, its essentially that asinine. Glad I spent 10 years in the industry and got my PhD to be judged on this algorithm....