What is wrong with the following solution for CHEFDIV for April 17 long?

problem link: CodeChef: Practical coding for everyone
My solution: CodeChef: Practical coding for everyone

I am calculating prime factors of numbers in the range from A to B and storing them in a set. Then on each step I am finding the number of divisors a number has and then dividing my current number with the prime factor that has the highest power. But somehow 0 is getting stored in the list of primes that I had generated in the set s. The solution gets an AC on 17 tasks out of 19, but fails on 2 tasks because somehow 0 is getting stored in the list of primes. I don’t understand why this happens. Thank you.