Joao_Joao

Questão 251 Lista de Exercícios IFPB

Jun 17th, 2022
1,314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int factorial (int n) {
  4.   if(n < 2) return 1;
  5.   return n * factorial(n-1);
  6. }
  7.  
  8. void main() {
  9.   int n;
  10.   printf("Digite o valor de N: ");
  11.   scanf("%d", &n);
  12.   printf("%d! = %d\n", n, factorial(n));
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment