aboutsummaryrefslogtreecommitdiffstats
path: root/misc/test.cpp
blob: 564b6f22f16011c1eb6366a63e75931d0088d0e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main () {
  unsigned long long x;
  cout << "Enter a number:";
  cin >> x;
  unsigned long long i = (x-1);
  int a;
  for (i=x; i>1; --i) {
    if (x%i==0 && x!=i) {
      cout << "Not prime!" << endl;
      a=1;
      break;
      return i;
    }
  }
  
  if (a!=1)
  cout << "Prime!" << endl;
  return 0;
}