fork(6) download
  1. (defun prime (a) ;;判斷質數的function
  2. (setq x (round (sqrt a))) ;;令x是小於根號a的數字
  3. (defun p (i)
  4. (if (= (mod a i) 0) ;;第一次呼叫是從最接近根號a的數字開始 餘數=0就不是質數
  5. ()
  6. (if (= (setq i (- i 1)) 1) ;;餘數!=0就把i-1 若i!=1表示還沒判斷完
  7. (print a)
  8. (p i) ;;沒判斷完就繼續呼叫
  9. )
  10. )
  11. )
  12. (if (= a 2)
  13. (print a) ;;如果a=2必為質數所以印出
  14. (p x) ;;其他放入p這個function判斷
  15. )
  16. )
  17.  
  18.  
  19. (do ;;((a 2(+ a 1)))
  20. ((= a 257)) ;;由1~1000一個一個放進function判斷
  21. (prime a)
  22. )
Runtime error #stdin #stdout #stderr 0.03s 10784KB
stdin
(prime 5)
stdout
Standard output is empty
stderr
*** - LET: variable A has no value