An Application of Prime Number

0
257
Prime Number

A prime number is a natural number greater than 1 which has no positive divisors other than 1 and itself. The composite number is a number which is not prime. The most important practical application of prime numbers is in cryptography.

Public-key cryptography algorithms has numerous and extremely important security applications. The algorithms are based on the fact that integer factorisation is a very hard problem. Time required to factorise integers into their prime factors grows (roughly) exponentially with the number of bits in the integer. So if the encryption uses very large integers, it would take an unrealistic amount of time to crack it.

In this article we have presented a simple program to check that number and then we print out whether the entered number is prime number or not.

#include <stdio.h>
int main()
{
  int number, i, isprime = 0;
  printf("\nEnter the positive integer to check for prime: ");
  scanf("%d",&number);
  for(i = 2; i <= sqrt(number); i++)
  {
    if( (number % i) == 0 )
    {
         isprime = 1;
         break;
    }
  }
  if(isprime == 1)
  {
    printf("\n%d is a Prime Number", number );
  }
  else{
    printf("\n%d is not a Prime Number", number);
  }
}

 

SHARE
Next articleAn Introduction to Artificial Intelligence
Dr R M Makwana
Dr. Makwana is Ph.D. in Computer Engineering, specialized in Artificial Intelligence from Sardar Patel University, Anand, Gujarat, India. Accelerated career growth from lecturer to professor in short span, having teaching experience of more than 13 years. He is TechSavvy with Research interest in Artificial Intelligence, Image Processing, Computer Vision, and Internet of Things. Actively supporting research community by providing service as a member of technical program committees of national and international conferences and workshops, as well as by reviewing journal and conference papers.

LEAVE A REPLY