Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. ;; EMACS VINCE
  2. ;; BRONSA SUCCHIA LATTE DA MATTINA A SERA
  3.  
  4.  
  5. #-sbcl (error "This only works using SBCL")
  6. (declaim (optimize (speed 3)
  7. (compilation-speed 0)
  8. (debug 0)
  9. (safety 0)))
  10.  
  11.  
  12.  
  13.  
  14. (defun pidigits (x-digits)
  15. (macrolet ((gen-arccot (sign opposite)
  16. `(,(intern (format nil "~a~a" 'arccot sign)) (x-rest n x-elevate product)
  17. (declare (type integer x-rest n))
  18. (declare (type bignum x-elevate product))
  19. (let ((term (floor x-elevate n)))
  20. (if (zerop term)
  21. product
  22. (,(intern (format nil "~a~a" 'arccot opposite)) x-rest (+ n 2)
  23. (the bignum (floor x-elevate x-rest))
  24. (the bignum (,(intern (format nil "~a" sign)) product term )))))))
  25. (labels ((gen-arccot + -)
  26. (gen-arccot - +))
  27. (let* ((limit (expt 10 (+ 10 x-digits)))
  28. (first-thread (sb-thread:make-thread
  29. (lambda () (* 44 (the bignum (arccot+ 3249 1 (the bignum (floor limit 57)) 1))))))
  30. (second-thread (sb-thread:make-thread
  31. (lambda () (* 7 (the bignum (arccot+ 57121 1 (the bignum (floor limit 239)) 1))))))
  32. (third-thread (sb-thread:make-thread
  33. (lambda () (* -12 (the bignum (arccot+ 465124 1 (the bignum (floor limit 682)) 1))))))
  34. (fourth-thread (sb-thread:make-thread
  35. (lambda () (* 24 (the bignum (arccot+ 167521249 1 (the bignum (floor limit 12943)) 1)))))))
  36. (declare (type bignum limit))
  37. (sb-thread:thread-yield)
  38. (format nil "3.~a" (the bignum (rem
  39. (the bignum (floor
  40. (the bignum (* 4
  41. (the bignum (+
  42. (the bignum (sb-thread:join-thread fourth-thread))
  43. (the bignum (sb-thread:join-thread third-thread))
  44. (the bignum (sb-thread:join-thread second-thread))
  45. (the bignum (sb-thread:join-thread first-thread))))))
  46. 10000000000))
  47. (/ limit 10000000000))))))))
  48.  
  49.  
  50. (if (not (cadr *posix-argv*))
  51. (format t "Errore: sei ebreo~%")
  52. (let ((n (parse-integer (cadr *posix-argv*))))
  53. (if (not (typep n 'integer))
  54. (print "The argument should be a integer~%")
  55. (print (pidigits n)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement