Advertisement
Advatre

fatorial_gbm

Aug 7th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. /* Autor: G. Brito M.
  2.  Curso: ABI - Ciência da Computação
  3.  Campus: IFB - Taguatinga
  4.  Data: 7/Agosto/2017
  5.  Este código pede ao usuário que digite um numero que ele deseja ter o fatorial.
  6. */
  7. #include<stdio.h>
  8.     double fat(int n){
  9.         int i=1;
  10.         double fatorial;
  11.     for (fatorial=1;n>i;n--){
  12.          fatorial=fatorial*n;
  13.         }
  14.     return(fatorial);
  15. }
  16.  
  17.     main(){
  18.     int n;
  19.     printf("\nDigite um número para receber seu fatorial: ");
  20.     scanf("%d",&n);
  21.     printf("O fatorial de %d ! = %.0f",n,fat(n));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement