(defun f (n m)
(let* ((result (* n m))
(length (1+ (length (princ-to-string result))))
(kugiri (make-string length :initial-element #\-)))
(format t "~@?~%x~@?~%~a~%~@?~a~% ~d~%"
(format nil "~~~dd" length) n
(format nil "~~~dd" (1- length)) m
kugiri
(format nil "~~{~~~d@a~%~~}" length)
(loop for c across (nreverse (princ-to-string m))
for space = 0 then (if (zerop i) space (+ space zero 1))
for zero = 0 then (if (zerop i) (1+ zero) 0)
for i = (* n (parse-integer (string c)))
unless (zerop i)
collect
(concatenate 'string
(princ-to-string i)
(make-string zero :initial-element #\0)
(make-string space :initial-element #\ )))
kugiri
result)))
(f 1234 1001)
(f 12 1999808070605040302010)
KGRlZnVuIGYgKG4gbSkKICAobGV0KiAoKHJlc3VsdCAoKiBuIG0pKQoJIChsZW5ndGggKDErIChsZW5ndGggKHByaW5jLXRvLXN0cmluZyByZXN1bHQpKSkpCgkgKGt1Z2lyaSAobWFrZS1zdHJpbmcgbGVuZ3RoIDppbml0aWFsLWVsZW1lbnQgI1wtKSkpCiAgICAoZm9ybWF0IHQgIn5AP34leH5AP34lfmF+JX5AP35hfiUgfmR+JSIKCSAgICAoZm9ybWF0IG5pbCAifn5+ZGQiIGxlbmd0aCkgbgoJICAgIChmb3JtYXQgbmlsICJ+fn5kZCIgKDEtIGxlbmd0aCkpIG0KCSAgICBrdWdpcmkKCSAgICAoZm9ybWF0IG5pbCAifn57fn5+ZEBhfiV+fn0iIGxlbmd0aCkKCSAgICAobG9vcCBmb3IgYyBhY3Jvc3MgKG5yZXZlcnNlIChwcmluYy10by1zdHJpbmcgbSkpCgkJICBmb3Igc3BhY2UgPSAwIHRoZW4gKGlmICh6ZXJvcCBpKSBzcGFjZSAoKyBzcGFjZSB6ZXJvIDEpKQoJCSAgZm9yIHplcm8gPSAwIHRoZW4gKGlmICh6ZXJvcCBpKSAoMSsgemVybykgMCkKCQkgIGZvciBpID0gKCogbiAocGFyc2UtaW50ZWdlciAoc3RyaW5nIGMpKSkKCQkgIHVubGVz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