• Home
  • About
    • Moon photo

      2019 OSS E4

      E4 is a team which is made in OSS Class in 2019 1st Semester

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects

Project Euler Prob.7

11 Jun 2019

Reading time ~1 minute

Problem

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?

Sol. 1

#include <stdio.h>

int main(void)
{
    int but, i;
    int count = 0;
    for (i = 2; ; i++) {
        but = 0;
        for (int j = 2; j <= i / 2; j++) {
            if (i % j == 0) but = 1;
        }
        if (but == 0) count++;
        if (count == 10001) break;
    }
    printf("%d", i);
}


Project Euler Share Tweet +1