summaryrefslogtreecommitdiff
path: root/p3
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2013-02-13 23:04:27 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2013-02-13 23:04:27 +0200
commitfc3ad977c54a060a2b8aab47a7cea9ece371f05d (patch)
treee1cb036d38f67ff462a50379bbb32eac2c5fd3bb /p3
parent77cdad53d8673c731718723250953f6c4ed5d504 (diff)
downloadeuler-c-fc3ad977c54a060a2b8aab47a7cea9ece371f05d.tar.gz
euler-c-fc3ad977c54a060a2b8aab47a7cea9ece371f05d.zip
problems 3 - 9
Diffstat (limited to 'p3')
-rw-r--r--p3/CMakeLists.txt7
-rw-r--r--p3/main.c30
2 files changed, 37 insertions, 0 deletions
diff --git a/p3/CMakeLists.txt b/p3/CMakeLists.txt
new file mode 100644
index 0000000..5f57337
--- /dev/null
+++ b/p3/CMakeLists.txt
@@ -0,0 +1,7 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(euler_problem3 C)
+INCLUDE_DIRECTORIES(../common)
+SET(SOURCES main.c ../common/utils.c)
+ADD_EXECUTABLE(p3 ${SOURCES})
+TARGET_LINK_LIBRARIES(p3 m)
+SET_SOURCE_FILES_PROPERTIES(${SOURCES} PROPERTIES COMPILE_FLAGS -g) \ No newline at end of file
diff --git a/p3/main.c b/p3/main.c
new file mode 100644
index 0000000..c72ba35
--- /dev/null
+++ b/p3/main.c
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "utils.h"
+
+int main(int argc, char **argv)
+{
+ // 90 = 2*3*3*5
+ // 17 = 17
+ // 147 = 3*7*7
+
+ long number = 600851475143;
+
+#include "primes_10000000.h"
+
+ list_t *factors = prime_factors_naive(prime_table, prime_table_size,
+ number);
+
+ list_t *curr = factors;
+ while (curr)
+ {
+ printf("%ld\n", *((long*)curr->value));
+ curr = curr->next;
+ }
+
+ list_free(factors, &list_free_long);
+
+ return 0;
+}