you could cache the results of
for i in range(2, number):
if number % i == 0:
break
else:
in a hashmap with key being number.
If I understand your code correctly, the inner loop computes "number % i" for 2 till number
for each number from 0 to 2,2000000000-1.
So if you save the results of the inner loop, you only need to compute "number % i" starting from last saved number till current number.