commit d295ee0eadf4a43fece665981ca8234a9937d518
parent f3a56ada478b93d3623a6f71d9c0e7b09bf77722
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date: Sun, 25 Oct 2020 15:52:34 -0300
Uploaded from linux bash terminal
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/factorial.c b/factorial.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(void) {
+
+ int fact, i, res;
+
+ printf("Ingrese un numero: ");
+ scanf("%i", &fact);
+
+ if(fact < 0) {
+ printf("Numero invalido\n");
+ return 1;
+ }
+
+ res = 1;
+ for(i = 1; 1 <= fact; i++) {
+ res = res * i;
+ }
+
+ printf("%d! = %d\n", fact, res);
+ return 0;
+}