By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <ctype.h>
 4 #include <math.h>
 5   
 6 int prim(int n)
 7 {
 8    int i;
 9    for(i=2; i*i<=n; i++)
10    {
11       if(n%i==0)
12         return 0;
13    }
14    return 1;
15 }
16   
17 void solve(int n)
18 {
19   int i=2;
20   int count=0;
21   while(1)
22   {
23      if(prim(i))
24      { 
25        count++;
26        if(count==n)
27          break;
28      }
29      i++;
30   }
31   printf("%d\n",i);
32 }
33   
34   
35 int main()
36 {
37   int n=10001;
38   solve(n);
39   return 0;
40 }

 

Answer:
104743

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-06-05
  • 2022-02-24
  • 2021-08-17
猜你喜欢
  • 2021-10-21
  • 2021-06-13
  • 2021-05-23
  • 2021-12-30
  • 2021-10-23
  • 2021-06-22
相关资源
相似解决方案