ace333 Posted September 20, 2005 Posted September 20, 2005 was given this problem in an interview... anyone got any ideas.... What initial values of a and c are required such that the final values of a and b are: a = 32 b = 4 � int a,b,c a = ? b = 0 c = ? for( b=0; a<12; b++ ) { a = (a+a) * c; } Quote
*Experts* Nerseus Posted September 20, 2005 *Experts* Posted September 20, 2005 If I were given that in an interview I'd have asked "Seriously?" There's no point in giving that in an interview. If they said "Yes, seriously" then I'd have walked out. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
ace333 Posted September 20, 2005 Author Posted September 20, 2005 a = 2 c = -1 can i ask u how long it took u to do that or what way of thinking help u solve the problem,,, i feel so stupid, i've been looking at this for an hour Quote
IngisKahn Posted September 20, 2005 Posted September 20, 2005 32 = 16ac^4 2 and 1 are the only integers that fit that equation and setting c to be negative flips the sign every other pass so that on the third iteration a is -16. It's pretty straight forward but I agree with Nerseus that it is a completely ridiculous question. Quote "Who is John Galt?"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.