2012-02-05から1日間の記事一覧

Problem 15

(require 'calc-ext) (defvar calc-command-flags nil) (defun factorial (n) (let ((rst 1)) (while (math-lessp 0 n) (setq rst (math-mul rst n)) (setq n (math-sub n 1)) ) rst )) (let ((size (string-to-number (car argv)))) (princ (math-format-va…

Problem 14

(require 'calc-ext) (defvar calc-command-flags nil) (let ((limit (math-add (math-read-number (car argv)) 1)) (hash (make-hash-table)) (i 1) (max-i 1)) (while (math-lessp i limit) (let ((n i) (len 0) found) (while (not (math-equal n 1)) (if…

Problem 16

(require 'calc-ext) (defvar calc-command-flags nil) (defun convert-decimal-to-binary (d) (let (b (i 0)) (while (> d 0) (setq b (cons (if (eq (% d 2) 0) 0 1) b)) (setq d (/ d 2)) (setq i (1+ i)) ) b)) (defun digits-sum (str) (let ((sum 0)) …