Pregunta de entrevista de Apple

Coding, embedded systems, operation systems

Respuesta de la entrevista

Anónimo

25 de jun de 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; }