summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/factorial.c8
-rw-r--r--test/factorial2.c (renamed from test/fibonacci2.c)3
-rw-r--r--test/fibonacci.c8
3 files changed, 9 insertions, 10 deletions
diff --git a/test/factorial.c b/test/factorial.c
new file mode 100644
index 0000000..0525b8f
--- /dev/null
+++ b/test/factorial.c
@@ -0,0 +1,8 @@
+int fact (int n) {
+ if (n) return n * fact(n-1);
+ else return 1;
+}
+
+int main (int argc, char** argv) {
+ return fact(argc);
+}
diff --git a/test/fibonacci2.c b/test/factorial2.c
index b8adb9a..867b709 100644
--- a/test/fibonacci2.c
+++ b/test/factorial2.c
@@ -1,7 +1,6 @@
int main (int argc, char** argv) {
- int n = argc;
int result = 1;
- for (; n; n = n - 1) {
+ for (int n = argc; n; n = n - 1) {
result = result * n;
}
return result;
diff --git a/test/fibonacci.c b/test/fibonacci.c
deleted file mode 100644
index a07c111..0000000
--- a/test/fibonacci.c
+++ /dev/null
@@ -1,8 +0,0 @@
-int fib (int n) {
- if (n) return n * fib(n-1);
- else return 1;
-}
-
-int main (int argc, char** argv) {
- return fib(argc);
-}