aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbraxtonhall2022-10-23 23:42:08 +0000
committerbraxtonhall2022-10-23 23:42:08 +0000
commit2927387ace15b664d80e2335084e50d478581733 (patch)
tree77e9c8475ba7c22d4b0e7ca7332abfbba199fe89
parent8c3619fcb5e01b14eeab69bfa8c88cd75ed16ac9 (diff)
Add Margo's fibs
-rw-r--r--README.md3
-rw-r--r--entries/margoseltzer/efficiency.c23
2 files changed, 26 insertions, 0 deletions
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