We can make this code much faster by not doing the reduce (which is constantly boxing and unboxing the numbers) and instead iterating through the list. It's doable in Clojure, though I'm ok with writing this code in Java and then calling it from here.