write an algorithm to divide two numbers using only loops and addition.
Respuestas de entrevistas
Anónimo
12 de may de 2010
delegate the problem to one of the mindless google calculator boys.
1
Anónimo
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
Anónimo
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!
Anónimo
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))
Anónimo
17 de may 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
Anónimo
17 de may 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....