mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-21 04:16:50 +08:00
| .. | ||
| main.c | ||
| README.md | ||
Section 3 - Pre-computation
Time versus space.
This is the essential battle that programmers face. In order to go faster, more memory is used. In order to economize on memory, more computation is needed.
This duality is demonstrated in no better way than comparing a calculated method (economizing space at the expense of time) versus an entirely precomputed method (sacrificing space to reduce time).
In this section, we will demonstrate three methods of calculating factorials from 0 to 15.
-
Iteratively
-
Recursively
-
By pre-computation
Certainly, for the purposes of this demonstration, it is not necessary to implement both iterative and recursive methods. We do so for fun and for any lessons the reader can glean.