Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Autor: G. Brito M.
- Curso: ABI - Ciência da Computação
- Campus: IFB - Taguatinga
- Data: 7/Agosto/2017
- Este código pede ao usuário que digite um numero que ele deseja ter o fatorial.
- */
- #include<stdio.h>
- double fat(int n){
- int i=1;
- double fatorial;
- for (fatorial=1;n>i;n--){
- fatorial=fatorial*n;
- }
- return(fatorial);
- }
- main(){
- int n;
- printf("\nDigite um número para receber seu fatorial: ");
- scanf("%d",&n);
- printf("O fatorial de %d ! = %.0f",n,fat(n));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement