summaryrefslogtreecommitdiffstats
path: root/mat
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mat/euler/11/meme.txt6
-rw-r--r--mat/euler/12/Makefile2
-rwxr-xr-xmat/euler/12/a.outbin0 -> 8568 bytes
-rw-r--r--mat/euler/12/prog.c33
4 files changed, 41 insertions, 0 deletions
diff --git a/mat/euler/11/meme.txt b/mat/euler/11/meme.txt
new file mode 100644
index 0000000..4886035
--- /dev/null
+++ b/mat/euler/11/meme.txt
@@ -0,0 +1,6 @@
+
+
+
+ Her: I only date bad boys.
+ Me: I don't check whether
+ malloc() failed or not!
diff --git a/mat/euler/12/Makefile b/mat/euler/12/Makefile
new file mode 100644
index 0000000..156bc0d
--- /dev/null
+++ b/mat/euler/12/Makefile
@@ -0,0 +1,2 @@
+default:
+ gcc prog.c -lm
diff --git a/mat/euler/12/a.out b/mat/euler/12/a.out
new file mode 100755
index 0000000..37a4114
--- /dev/null
+++ b/mat/euler/12/a.out
Binary files differ
diff --git a/mat/euler/12/prog.c b/mat/euler/12/prog.c
new file mode 100644
index 0000000..7af0f37
--- /dev/null
+++ b/mat/euler/12/prog.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main (int argc, char ** argv) {
+ if (argc != 1 + 1) {
+ fprintf(stderr, "uporaba: %s <stevilka>, \nprimer: %s 500\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned long int n = strtol(argv[1], NULL, 10);
+ unsigned long long int i = 1;
+ unsigned long long int j = 0;
+ unsigned long long int d = 0;
+ unsigned long long int s = 0; // dejansko trikotniško število.
+ while (1) {
+ s = s+i;
+ fprintf(stderr, "\rpreizkušam število %lld ...", i);
+ d = 0;
+ for (j = 2; j < ceill(sqrtl(s)); j++) {
+ if (s % j == 0)
+ d++;
+ }
+ d = (d*2)+2; // dva dodamo, ker sta to število samo in 1
+ if (d > n) {
+ fprintf(stdout, "\rnašel število %lld z %lld delitelji\n", s, d);
+ return 0;
+ }
+ i++;
+ if (i <= 1) // int rollover
+ break;
+ }
+ fprintf(stderr, "napaka. intager rollover pred najdenim rezultatom!\n");
+ return 2;
+}