Prime number
- A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers.
- The property of being prime is called primality
Facts about Prime number
- 2 is the only prime number.
- If the sum of the number’s digits is multiple of 3, that number can be divided by 3.
- No prime number greater than 5 ends with 5.
- 0 and 1 are not considered prime numbers.
- The largest known prime number (as of December 2020) is 2^82,589,933 − 1, a number that has 24,862,048 digits when written in base 10. It was found via a computer volunteered by Patrick Laroche of the Great Internet Mersenne Prime Search (GIMPS) in 2018.
C program for checking Primality
- #include<stdio.h>
- int main()
- {
- int num;
- int i;
- int m=0;
- int flag=0;
- printf("Enter a number to check prime or not\n");
- scanf("%d",&num);
- m = num/2;
- for(i = 2; i <= m;i++)
- {
- if(num%i == 0)
- {
- printf("Number is NOT prime\n");
- return 0;
- }
- }
- if(flag==0)
- printf("Number is prime\n");
- return 0;
- }
0 Comments
If you have any doubts, Please let me know