Sieve of Eratosthenes

I have found the code from MAXimal

int n;
vector<char> prime (n+1, true);
prime[0] = prime[1] = false;
for (int i=2; i<=n; ++i)
	if (prime[i])
		if (i * 1ll * i <= n)
			for (int j=i*i; j<=n; j+=i)
				prime[j] = false;

why they use multiplication by 111 on 6th line of code

That’s not 111, it’s 1ll(1 L L). Since, i*i can pass the range of int and here it typecast int into long long.

2 Likes
//