Concept required

Which concept is required to solve this problem

@rkrishna this problem will be solve using Sieve of Eratosthenes .