Why Julia is so much slower than Python? Invitation to Euler Project

The funny thing is that I didn’t think of digits at first and instead used string and apparently its way faster than using the built in digits function, as this allocates. Inspecting this I found that

julia> euler20(n) =  mapreduce(x->Int(x)-48,+,string(factorial(big(n))))
euler20 (generic function with 1 method)

julia> @btime euler20(100)
  1.190 μs (13 allocations: 544 bytes)
648
4 Likes