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. (if (> n 100)
  15. (let ((num-digits-over-hundred (- (ceiling (log n 10)) 3)))
  16. (+ (* (truncate n 100) 25) (- (zeros (fac (rem n 100))) num-digits-over-hundred)))
  17. (zeros (fac n))))
  18.  
  19. (loop repeat (read)
  20. do (format t "~A~%" (zero-fac (read))))
Success #stdin #stdout 0.02s 10632KB
stdin
6
3
60
100
1024
23456
8735373
stdout
0
14
24
253
5861
2183837