Advertisement
Mastercpp

calcular potencia sin usar Math

Feb 2nd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int  potencia(int base,int exponente){
  5.     int resultado=1;
  6.     for(int i=1; i<=exponente; i++){
  7.         resultado *=base;
  8.     }
  9.     return resultado;
  10. }
  11.  
  12. int main(){
  13.     cout << potencia(5,3) << endl;
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement