From 96e61378343e7b84d33774a09be9fc94aa66a3be Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Thu, 7 Feb 2019 21:36:19 +0000 Subject: Bored in Lecture? Find prime numbers! --- misc/test.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 misc/test.cpp (limited to 'misc/test.cpp') diff --git a/misc/test.cpp b/misc/test.cpp new file mode 100644 index 0000000..493114a --- /dev/null +++ b/misc/test.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +using namespace std; + +int main () { + unsigned long long x; + int a; + cout << "Enter a number:"; + cin >> x; + unsigned long long i = (x-1); + + for (i=x; i>1; --i/*--*/) { + if (x%i==0 && x!=i) { + cout << "Not prime!" << endl; + a=1700; + break; + return 3; + } + } + + if (a!=1700) + cout << "Prime!" << endl; + return 0; +} \ No newline at end of file -- cgit v1.2.3