Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Código para retirar dúvida em fórum.
- #include <stdlib.h>
- #include <stdio.h>
- int fat(int val)
- {
- if(val<=0 || val >=16 ){return -1;}
- int x=val-1;
- int res=val;
- while(x > 1)
- {
- res = res * x;
- x--;
- }
- return res;
- }
- int main()
- {
- int x=0;
- while(x!=-1)
- {
- scanf("%d",&x);
- printf("%d",fat(x));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment