diff options
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | p10/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | p10/main.c | 25 |
3 files changed, 33 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c39f493..70dd864 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,3 +8,4 @@ add_subdirectory(p6) add_subdirectory(p7) add_subdirectory(p8) add_subdirectory(p9) +add_subdirectory(p10) diff --git a/p10/CMakeLists.txt b/p10/CMakeLists.txt new file mode 100644 index 0000000..5fd478e --- /dev/null +++ b/p10/CMakeLists.txt @@ -0,0 +1,7 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(euler_problem10 C) +INCLUDE_DIRECTORIES(../common) +SET(SOURCES main.c ../common/utils.c) +ADD_EXECUTABLE(p10 ${SOURCES}) +TARGET_LINK_LIBRARIES(p10 m) +SET_SOURCE_FILES_PROPERTIES(${SOURCES} PROPERTIES COMPILE_FLAGS -g) diff --git a/p10/main.c b/p10/main.c new file mode 100644 index 0000000..08e3975 --- /dev/null +++ b/p10/main.c @@ -0,0 +1,25 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "utils.h" + +int main(int argc, char **argv) +{ + long i; + long sum = 2; + + for (i = 3; i < 2000000; ++i) + { + int p = is_prime_rabmil(i, 30); + + if (p) + { + sum += i; + } + } + + printf("%ld\n", sum); + + return 0; +} + |
