diff options
author | braxtonhall | 2022-10-23 23:42:08 +0000 |
---|---|---|
committer | braxtonhall | 2022-10-23 23:42:08 +0000 |
commit | 2927387ace15b664d80e2335084e50d478581733 (patch) | |
tree | 77e9c8475ba7c22d4b0e7ca7332abfbba199fe89 | |
parent | 8c3619fcb5e01b14eeab69bfa8c88cd75ed16ac9 (diff) |
Add Margo's fibs
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | entries/margoseltzer/efficiency.c | 23 |
2 files changed, 26 insertions, 0 deletions
@@ -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 |