Prime numbers are divisible only by 1 and by themselves. 2,3,5,7,11 etc are prime numbers. These numbers are only divisible by 1 and by themselves. To check whether a given number is prime number or not, at first, we start a loop from 1 to given number and check as if it is divisible the loop incremented number and if it is, then we will print that given number is prime number and also if it is 2, we will directly check it and print that given number is prime number. Have a look here,
The Output
If you have any doubt, let me know...