-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.cpp
More file actions
17 lines (15 loc) · 802 Bytes
/
prime.cpp
File metadata and controls
17 lines (15 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <cmath>
using namespace std ;
//Testing out weird formatting to see if it works
int main() {
unsigned long input ;
while (cin >> input) {
bool isPrime = true ;
if (input % 2 == 0 && input != 2) {
isPrime = false ;}
for (int i = 3; i < sqrt(input) + 1; i+=2) {
if (input % i == 0)
isPrime = false ;}
cout << isPrime << endl ;}
return 0 ;}