Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- long fact(int n);
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- int main()
- {
- int N;
- scanf("%d", &N);
- // Write an answer using printf(). DON'T FORGET THE TRAILING \n
- // To debug: fprintf(stderr, "Debug messages...\n");
- if (N < 0) {
- printf("No negative integers");
- } else {
- printf("%ld\n", fact(N));
- }
- return 0;
- }
- long fact(int n) {
- if (n == 0 || n == 1) return 1;
- return n * fact(n-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement