Advertisement
renix1

fat in c

Mar 2nd, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. # include <stdio.h>
  2.  
  3. int fat(n) {
  4.     int resultado = 1, f = n;
  5.     while (f > 1) {
  6.         resultado *= f;
  7.         f -= 1;
  8.     }
  9.     return resultado;
  10. }
  11.  
  12. int main(void) {
  13.     int n = 0;
  14.     printf("n: ");
  15.     scanf("%d", &n);
  16.     printf("%d\n", fat(n));
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement