From 2927387ace15b664d80e2335084e50d478581733 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Sun, 23 Oct 2022 16:42:08 -0700 Subject: Add Margo's fibs --- README.md | 3 +++ entries/margoseltzer/efficiency.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 entries/margoseltzer/efficiency.c diff --git a/README.md b/README.md index d126e3b..d43be80 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G ### [`jyoo980`](https://github.com/jyoo980) - [`scala`](./entries/jyoo980/scala/Fib.scala) +## [`margoseltzer`](https://github.com/margoseltzer) +- [`efficiency`](./entries/margoseltzer/efficiency.c) + ### [`Metroxe`](https://github.com/Metroxe) - [`html`](./entries/Metroxe/index.html) diff --git a/entries/margoseltzer/efficiency.c b/entries/margoseltzer/efficiency.c new file mode 100644 index 0000000..6e017f3 --- /dev/null +++ b/entries/margoseltzer/efficiency.c @@ -0,0 +1,23 @@ +unsigned long foo(unsigned long n) { + if (n < 2) return (n); + return(foo(n - 1) + foo(n - 2)); +} + +// Efficiency of expression + +unsigned long bar(unsigned long n) { + unsigned long i, last; + unsigned long sum, tmp; + + if (n < 2) return (n); + last = 0; + sum = 1; + for (i = 2; i <= n; i++) { + tmp = sum; + sum += last; + last = tmp; + } + return (sum); +} + +// Efficiency in resource utilization -- cgit v1.2.3-70-g09d2