Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/10/2014, 00:30
Avatar de Profesor_Falken
Profesor_Falken
 
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 9 meses
Puntos: 182
Respuesta: Algoritmo potencia

Código C:
Ver original
  1. int pow(int base, int exp)
  2. {
  3.     int result = 1;
  4.     while (exp)
  5.     {
  6.         if (exp & 1)
  7.             result *= base;
  8.         exp >>= 1;
  9.         base *= base;
  10.     }
  11.  
  12.     return result;
  13. }

Un saludo
__________________
If to err is human, then programmers are the most human of us