Apple interview question

Coding, embedded systems, operation systems

Interview Answer

Anonymous

25 Jun 2024

int multiply(int a, int b) { int result = 0; // Loop until a becomes zero while (a > 0) { if (a % 2 == 1) { // If a is odd, add it the result result += b; } b = b > 1; // Halve the a } return result; }