Prime visit runtime error

https://ide.codingblocks.com/s/52264
I have to find primes between two numbers and I am using prime sieves but it is giving me runtime error for sieve_size>10^5

Hey Siddharth, when you are taking the data type of n as long long int then the data type of variable i that’s iterating from i=3 to i=n should also be long long int. See if n is a number of range long long int then how an int type variable i will iterate till n in the loop.

https://ide.codingblocks.com/s/52264
still facing the same issue

Hey Siddharth, you haven’t taken the data type long long int at every required place and to declare an array of such a big size you can declare the array globally. Here i have corrected your code you can refer this.

1 Like