void test function

For a project i am asked to find primes from 1 to x and then use the number of primes to solve the Prime number theorem, which i did but prof doesn't want us to post code so idk if asking this way will be helpful with out the code. So i am suppose to use void test function which i never used and i am confused how it works. the only example he gave is:

Test function
1
2
3
  void test(int a, int n);
//
test(2,5);


The output may be

i=1, pnt(2*10^1)=1.19829
i=2, pnt(2*10^2)=1.21861
i=3, pnt(2*10^3)=1.15154
i=4, pnt(2*10^4)=1.12008
i=5, pnt(2*10^5)=1.09757


I don't know if it's possible to explain it to me about how this works but if you can or give a example of something similar that will be very helpful.
Last edited on
What do you mean by "solve the Prime number theorem"? The theorem says that a number with 2n digits is half as likely to be prime as a number with n digits (for large enough n). You may be testing the theorem, but I doubt you'll be "solving" (proving?) it.

The "test" function is one that you need to write. You are given the prototype which shows it takes two integers: a and n. You must have been told what those parameters mean, so what are they?

Then you show some output whose meaning I can only guess at. You must have been told what it means, so what is it? What is pnt? What's up with the powers of 10? Why are they multiplied by 2? I could guess, but why should I? You must have been told this otherwise the assignment is senseless.
well not solving it just using the theorem like when number of prime from 1 to 20 is 8, so i did 8*1.0/(20/log(20)) which gave me 1.19829. The out line is:
1
2
3
4
5
6
7
8
9
10
11
12
13
typedef unsigned long long ull; 
ull pi(ull x){

}
double pnt(ull x){
}
void test(int a, int n){

}
//...
int main(){

}


pnt(x) uses the Prime number theorem, pi(x) is for the number of primes. But i don't get what void test(int a, int n) i asked my professor over the email he gave this as example:
1
2
3
void test(int a, int n);
//
test(2,5);



i=1, pnt(2*10^1)=1.19829
i=2, pnt(2*10^2)=1.21861
i=3, pnt(2*10^3)=1.15154
i=4, pnt(2*10^4)=1.12008
i=5, pnt(2*10^5)=1.09757



After going over the output few more time i think i was looking at it the wrong way since i never used void before, i am going to try it and see if i get the same output.
Last edited on
This description matches the given output:
1
2
// Loop i from 1 to n. In each iteration, compute pnt(a*10^i) and print the result.
void test(int a, int n);
Topic archived. No new replies allowed.