fork download
  1. (defun fac (n)
  2. (loop for result = 1 then (* result i)
  3. for i from 2 to n
  4. finally (return result)))
  5.  
  6. (defun zeros (n)
  7. (loop for num = n then (/ num 10)
  8. for zero = (zerop (rem num 10))
  9. until (null zero)
  10. summing 1 into result
  11. finally (return result)))
  12.  
  13. (defun zero-fac (n)
  14. (let ((num-digits-over-hundred (- (ceiling (log n 10)) 3)))
  15. (+ (* (truncate n 100) 25) (- (zeros (fac (rem n 100))) num-digits-over-hundred))))
  16.  
  17. (loop repeat (read)
  18. do (format t "~A~%" (zero-fac (read))))
Success #stdin #stdout 0.03s 10632KB
stdin
6
3
60
100
1024
23456
8735373
stdout
2
15
26
253
5861
2183837