Write a program to check whether a number is prime or not. Given an integer, We have to write an efficient to check whether a number is prime or not.

### Categories

### Interview Questions

Technology Blog Where You Find Programming Tips and Tricks

Write an efficient program to generate prime numbers between 1 to N (Where N is 10, 100, 1000 etc). This question can also be asked like this, Generate prime numbers between 1 to 100 or 1 to 10 etc.

Suppose the value of N is 10, So the prime numbers between 1 to 10 is 2, 3, 5, 7. Now let’s learn the most efficient algorithm (**Sieve of Eratosthenes**) to generate Prime Numbers between 1 to N. Before solving this program, let’s understand what is a prime number.