-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime_number.cpp
More file actions
51 lines (40 loc) · 1.13 KB
/
prime_number.cpp
File metadata and controls
51 lines (40 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
void range(int low, int upper);
int main(){
int low;
int upper;
std::cout << "PRIME NUMBER IN RANGE" << '\n';
std::cout << "------------------------------------------" << '\n';
std::cout << "Introduce a lower limit and an upper limit" << '\n';
//std::cout << "LOWER LIMIT (except negative numbers and 1): ";
do{
std::cout << "LOWER LIMIT (except negative numbers and 1): ";
std::cin >> low;
}while(low <= 1);
do{
std::cout << "UPPER LIMIT (except negative numbers and 1): ";
std::cin >> upper;
}while(upper <=1 );
range(low, upper);
return 0;
}
void range(int low, int upper){
int y;
for (int i = low; i <= upper; i++){
int count = 0;
for (int z = low; z <= upper; z++){
//y = i/z;
y = i%z;
//int count = 0;
if(y == 0){
//std::cout << "*";
count++;
}
}
if(count == 1){
std::cout << i << '\n';
//std::cout << " " << count;
}
//std::cout << '\n';
}
}