diff options
| author | 2025-11-16 12:11:18 +0100 | |
|---|---|---|
| committer | 2025-11-16 12:11:18 +0100 | |
| commit | 111e71e1511b2abff9176bd6c714c8da796f770e (patch) | |
| tree | 352b723c9144c844037447bd865a8366378df7a5 /test/fib.c | |
| parent | b0c0f2d2d885c5901de08ed08dba9fff079bf6e3 (diff) | |
basic automated testing
Diffstat (limited to 'test/fib.c')
| -rw-r--r-- | test/fib.c | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/test/fib.c b/test/fib.c deleted file mode 100644 index 806b416..0000000 --- a/test/fib.c +++ /dev/null @@ -1,36 +0,0 @@ -unsigned fib(unsigned x) { - unsigned r = 0, q = 1; - for (; x > 1; --x) { - unsigned s = r + q; - r = q; - q = s; - } - return q; -} - -unsigned fibr(unsigned x) { - if (x < 2) return x; - return fibr(x-1) + fibr(x-2); -} - -double fibf(unsigned x) { - double r = 0., q = 1.; - while (x-- > 1) { - double s = r + q; - r = q; - q = s; - } - return q; -} - -int atoi(const char *); -int printf(const char *, ...); - -int main(int argc, char **argv) { - unsigned n = argv[1] ? atoi(argv[1]) : 10; - printf("fib(%u) = %u\n", n, fib(n)); - printf("fibf(%u) = %g\n", n, fibf(n)); - printf("fibr(%u) = %u\n", n, fibr(n)); -} - -/* vim:set ts=3 sw=3 expandtab: */ |