Calcular Fatorial Em C

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Calcular Fatorial Em C as PDF for free.

More details

  • Words: 56
  • Pages: 1
#include <stdio.h> #include <stdlib.h> int main(void){ int n,f,i; printf("Digite um numero que voce queira obter o fatorial\n"); scanf("%d",&n); if(n<0) printf("Nao existe fatorial de numeros negativos\n"); else{ if(n==0 || n==1) printf("Fatorial de %d = 1\n",n); else{ if(n==2) printf("Fatorial de 2 = 2\n"); else{ f=n; for(i=n;i>=2;i--) f=f*(i-1); printf("Fatorial de %d = %d\n",n,f); } } } return 0; }

Related Documents