[SOLVED] Overflow error

I’m getting an overflow error that I can’t figure out a way out of.
Code should be here.
The problematic portion appears to be this call in the sieve function:

.each { |i| 
        (i*i..limit).step(2*i).each { |j| prime_indices[j] = false }
    }

I don’t fully understand the error message, which on my local machine is

Arithmetic overflow (OverflowError)
from src/prime_factors.cr:0:43 in ‘->’
from /usr/lib/crystal/iterator.cr:255:3 in ‘next’
from src/prime_factors.cr:489:15 in ‘sieve’
from src/prime_factors.cr:266:5 in ‘factors’
from spec/prime_factors_spec.cr:30:49 in ‘->’
from /usr/lib/crystal/spec/example.cr:255:3 in ‘internal_run’
from /usr/lib/crystal/spec/example.cr:35:16 in ‘run’
from /usr/lib/crystal/spec/context.cr:296:23 in ‘internal_run’
from /usr/lib/crystal/spec/context.cr:291:7 in ‘run’
from /usr/lib/crystal/spec/context.cr:48:23 in ‘run’
from /usr/lib/crystal/spec/dsl.cr:270:7 in ‘->’
from /usr/lib/crystal/kernel.cr:255:3 in ‘run’
from /usr/lib/crystal/crystal/main.cr:47:5 in ‘main’
from /usr/lib/crystal/crystal/main.cr:106:3 in ‘main’
from __libc_start_main
from _start
from ???

How do I interpret the error message to figure out the necessary change to the sieve function?

+++++++++++++++++++

Figured it out. It was the i*i call that was potentially overflowing. instead of checking i*i < limit I needed to check i < Math.sqrt(limit).