Problem 7
(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))) )))) (let ((idx-searched (string-to-number (car argv))) (idx 0) (n 1) (prime)) (while (< idx idx-searched) (setq n (1+ n)) (if (not (find-factor n)) (progn (setq idx (1+ idx)) (setq prime n) ))) (princ n) (princ "\n") )
メモ
- 割と実行に時間がかかった.
- 多倍長の必要はなかった.