(require 'cl)
(require 'calc-ext)
(defvar calc-command-flags nil)
(defun find-factor (num)
(catch 'found
(let ((i 2))
(while (math-lessp (math-sub i 1) (math-floor (math-sqrt num)))
(if (math-equal (math-mod num i) 0)
(throw 'found i)
(setq i (math-add i 1))) ))))
(defun count-factor (num)
(if (= num 1) 1
(let ((p-table (make-hash-table)) p val lst)
(while (setq p (find-factor num))
(setq num (/ num p))
(if (setq val (gethash p p-table))
(puthash p (1+ val) p-table)
(puthash p 1 p-table) ))
(if (setq val (gethash num p-table))
(puthash num (1+ val) p-table)
(puthash num 1 p-table) )
(maphash #'(lambda (key val) (push (1+ val) lst)) p-table)
(apply #'* lst) )))
(let (rst)
(do* ((i 1 (1+ i))
(triangle i (+ triangle i)))
(rst)
(if (> (count-factor triangle) (string-to-number (car argv)))
(setq rst triangle) ))
(princ rst)
(princ "\n") )