Advertisement
Dr4noel

Numar factorial!

Dec 4th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. void main() {
  5.     int n, i, factorial = 1;
  6.  
  7.     printf("Inserati un numar intreg: \n");
  8.     scanf_s("%d", &n);
  9.  
  10.     if (n == 0) {
  11.         printf("0! = 1");
  12.     }
  13.     else if (n >= 1) {
  14.  
  15.         for (i = 1; i <= n; i++) {
  16.             factorial = factorial * i;
  17.         }
  18.  
  19.         printf("%d!= %d", n, factorial);
  20.  
  21.     }
  22.  
  23.     _getch();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement