Download Runnable Program
Program:
;Abundant numbers
(defun abn(n)
(format t "<<<GENERATING ABUNDANT NUMBERS IN THE RANGE 1 TO ~D" N)
;; (setf sum 1)
(do((i 1 (+ i 1))) ((= i (+ n 1)))
(setf sum (sumd i) dbl (* 2 i))
(if(> sum dbl) (print i))
)
)
(defun sumd(n)
(setf m (floor n 2))(setf sum 1 )
(do((i 2(+ i 1))) ((> i m))
(if(= (mod n i) 0)
(setf sum (+ sum i) )
)
)
(setf sum (+ sum n) )
sum
)
Output:
Break 2 [4]> (load 'abn.lsp)
;; Loading file abn.lsp ...
;; Loaded file abn.lsp
T
Break 2 [4]> (abn 50)
<<<GENERATING ABUNDANT NUMBERS IN THE RANGE 1 TO 50
12
18
20
24
30
36
40
42
48
NIL
Break 2 [4]>
Download
Program:
;Abundant numbers
(defun abn(n)
(format t "<<<GENERATING ABUNDANT NUMBERS IN THE RANGE 1 TO ~D" N)
;; (setf sum 1)
(do((i 1 (+ i 1))) ((= i (+ n 1)))
(setf sum (sumd i) dbl (* 2 i))
(if(> sum dbl) (print i))
)
)
(defun sumd(n)
(setf m (floor n 2))(setf sum 1 )
(do((i 2(+ i 1))) ((> i m))
(if(= (mod n i) 0)
(setf sum (+ sum i) )
)
)
(setf sum (+ sum n) )
sum
)
Output:
Break 2 [4]> (load 'abn.lsp)
;; Loading file abn.lsp ...
;; Loaded file abn.lsp
T
Break 2 [4]> (abn 50)
<<<GENERATING ABUNDANT NUMBERS IN THE RANGE 1 TO 50
12
18
20
24
30
36
40
42
48
NIL
Break 2 [4]>
Download
0 comments:
Post a Comment