-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDPZKPP1.2.cpp
More file actions
49 lines (48 loc) · 1.44 KB
/
Copy pathDPZKPP1.2.cpp
File metadata and controls
49 lines (48 loc) · 1.44 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
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
int main(){
cout << "DPZK Prime Program" << endl ;
cout << "PLEASE INPUT AS INTRODUCTION" << endl << "FAILED TO DO SO MAY CAUSE INFINITE LOOP" << endl;
while(1){
unsigned long long int r1, r2,x=2;
ofstream opt("output.txt", ios::trunc);
//cin >> x;
cout << "Please input the range" << endl;
cin >> r1 >> r2;
bool n=true;
int c=0;
cout << "Starting Program:" << endl << "2" << " ";
opt << "Prime from " <<r1 << "to " << r2 << endl << "2" << " ";
for(unsigned long long int in=r1;in<=r2;in++){
if(in%x==0){
n=false;
}else{
for(unsigned long long int i=2;i<=in/x;i++){
//cout << "d:"<< i << " ";
if(in%i==0){
n=false;
break;
}
}
}
if(n){
cout << in << " ";
opt << in << " ";
c++;
}
if(c%500==0&&n==true){
x=sqrt(2*in)*0.5;
//cout << "d;" <<x << " " << in << " ";
}
n=true;
}
cout << endl << "Count is ";
opt << endl << "Count is ";
cout << c+1 << endl;
opt << c+1 << endl;
opt.close();
c=0;
}
}