Advertisement
Schknheit

Fatorial

Apr 10th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main(){
  5.  
  6. int potencia,base,cont,teste;
  7. printf("Entre com dois valores maiores que zero: ");
  8. scanf("%d%d",&base,&potencia);
  9. teste = base;
  10. for(cont=1;cont<potencia;cont++){
  11. base=base*teste;
  12. }
  13. printf("resultado %d",base);
  14.  
  15. /*
  16. int x,cont;
  17. int fatorial = 1;
  18. printf("Entre com um valor maior que zero: ");
  19. scanf("%d",&x);
  20. for(cont=1;cont<=x;cont++){
  21. fatorial = fatorial*cont;
  22.  
  23. }
  24. printf("O fatorial de %d eh %d",x,fatorial);
  25.  
  26. */}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement