summaryrefslogtreecommitdiff
path: root/c/factorial.c
blob: 4ee07206d086a483be58d2ff3ed9d648db0b83e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>

long fact(long n) {
  if (n == 0) {
    return 1;
  }
  else return(n*fact(n-1));
}

int main() {
  printf("enter a POSITIVE integer... ");
  long input;
  scanf("%d", &input);
  long output = fact(input);
  printf("output: %lld\n", output);

  return 0;
}