aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-04-07 03:40:19 +0630
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-04-07 03:40:19 +0630
commit9bf1d123b8b66431dcb5d281f4850bd21a620037 (patch)
tree2940375c33fb206460e70c7c8bc4d942e66309a2
parent04a27bcfecd65c2864ff9b00cae63d8057a42ce3 (diff)
downloadovm-9bf1d123b8b66431dcb5d281f4850bd21a620037.tar.gz
ovm-9bf1d123b8b66431dcb5d281f4850bd21a620037.tar.bz2
ovm-9bf1d123b8b66431dcb5d281f4850bd21a620037.zip
Changed limit for examples/factorial.asm
Did some analysis and found that 21! takes above 64 bit integers to store hence set the limit to 20 instead.
-rw-r--r--examples/factorial.asm9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/factorial.asm b/examples/factorial.asm
index 42c0785..54fc956 100644
--- a/examples/factorial.asm
+++ b/examples/factorial.asm
@@ -1,9 +1,12 @@
;;; factorial.asm: A program that generates the factorials of each
-;;; number from 1 to 22 (22!~=UINT64_MAX). Using the registers to
-;;; store `n` and `n!`.
+;;; number from 1 to 20. Using the registers to store `n` and `n!`.
;; Constants
- %const(limit) 22 %end
+ ;; Choice of 20 was not arbitrary; log(20!) ~= 61 while log(21!) ~=
+ ;; 65 which means that past 20! results are truncated and therefore
+ ;; the program produces inaccurate factorials.
+
+ %const(limit) 20 %end
;; Setup entrypoint
global main