Thursday, 24 January 2013

check of prime

#include <iostream>

using namespace std;

int main()
{
    int num;
    bool prime;
    cin >> num;

    for (int i=2;i <=num-1;i++)
    {
      num%i;
      if(num%i==0)
      {
          cout << "not prime";

      break;
      }
      else if(num%i==1)
      {
          cout << "prime";
          break;
      }




     }








cin.get();
    return 0;
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management