Complete the function getNumberOfPrimes which takes in an integer N as its parameter,
to return the number of prime numbers that are less than N
Sample Testcases:
Input #00:
100
Output #00:
25
Input #01:
1000000
Output #01:
78498
int getNumberOfPrimes(int N) {
int i=0;
int total =0;
int j,k;
for(i=2;i<=N;i++)
{
if(i==2 ||i==3||i==5||i==7)
{
total++;
continue;
}
j=sqrt(i);
for(k=2;k<=j;k++)
{
if(i%k==0)
break;
}
if(k>j)
total++;
}
return total;
}
testcase:
2/2 testcases passed
TestCase #0
Status: Passed
Your output:
25
TestCase #1
Status: Passed
Your output:
78498