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.
This commit is contained in:
2024-04-07 03:40:19 +06:30
parent 04a27bcfec
commit 9bf1d123b8

View File

@@ -1,9 +1,12 @@
;;; factorial.asm: A program that generates the factorials of each ;;; factorial.asm: A program that generates the factorials of each
;;; number from 1 to 22 (22!~=UINT64_MAX). Using the registers to ;;; number from 1 to 20. Using the registers to store `n` and `n!`.
;;; store `n` and `n!`.
;; Constants ;; 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 ;; Setup entrypoint
global main global main