diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-07-21 14:36:02 -0700 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-07-21 14:36:02 -0700 |
| commit | 0cabbd2a0853c332c82af621b8716643741d758a (patch) | |
| tree | 4d1772e07ff1b81e00b563f877c6f1ead3305a8d /test | |
| parent | f87e953223b7d498fc5401247952c08ab1e08f93 (diff) | |
| download | ccc-0cabbd2a0853c332c82af621b8716643741d758a.tar.gz | |
more faithful grammar
Diffstat (limited to 'test')
| -rw-r--r-- | test/factorial.c | 8 | ||||
| -rw-r--r-- | test/factorial2.c (renamed from test/fibonacci2.c) | 3 | ||||
| -rw-r--r-- | test/fibonacci.c | 8 |
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); -} |
