-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetDown.h
61 lines (54 loc) · 1.04 KB
/
GetDown.h
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
52
53
54
55
56
57
58
59
60
61
#include<iostream>
#include <fstream>
using namespace std;
class GetDown
{
private:
int P[3249];//to store primes
int D[3249];//to store differences in consecative primes
public:
GetDown()
{
P[0]=1;
for(int i=1;i<3249;i++)
{
char *inname = "prime.txt";
ifstream infile(inname);
int j=0;
while (infile >> i)
{
P[j]=i;
j=j+1;
}
D[0]=1;
for(int i=1;i<3249;i++)
{
D[i]=P[i]-P[i-1];
}
}
};
int GoDown(int a,int i);
int Search(int r);
int display(int i);
};
int GetDown::GoDown(int a,int i)
{
a=a-D[i];
return a;
}
int GetDown::Search(int k)
{
int i=0;
while(P[i]<=k)
{
i=i+1;
}
i=i-1;
return i;
}
int GetDown::display(int i)
{
int p;
p = P[i];
return p;
}