Advertisement
mahatma_xande

ex03lista05

Aug 22nd, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. /*
  2. It calculates the factorial of a given natural number n.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main(){
  8.  
  9.     int n, w = 1;
  10.  
  11.     printf("Enter n: ");
  12.     scanf("%d", &n);
  13.  
  14.     while(n > 0){
  15.         w = w*n;
  16.         n = n - 1;
  17.     }
  18.  
  19.     printf("%d\n", w);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement