summaryrefslogtreecommitdiffstats
path: root/mat/euler/1
diff options
context:
space:
mode:
Diffstat (limited to 'mat/euler/1')
-rw-r--r--mat/euler/1/Makefile2
-rwxr-xr-xmat/euler/1/a.outbin0 -> 8480 bytes
-rw-r--r--mat/euler/1/prog.c23
3 files changed, 25 insertions, 0 deletions
diff --git a/mat/euler/1/Makefile b/mat/euler/1/Makefile
new file mode 100644
index 0000000..2def8af
--- /dev/null
+++ b/mat/euler/1/Makefile
@@ -0,0 +1,2 @@
+default:
+ gcc prog.c
diff --git a/mat/euler/1/a.out b/mat/euler/1/a.out
new file mode 100755
index 0000000..abe5144
--- /dev/null
+++ b/mat/euler/1/a.out
Binary files differ
diff --git a/mat/euler/1/prog.c b/mat/euler/1/prog.c
new file mode 100644
index 0000000..f152200
--- /dev/null
+++ b/mat/euler/1/prog.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+ if (argc != 1+3) {
+ fprintf(stderr, "uporaba: %s <max> <a> [b c d e ...]\nprimer, ki do 1000 izpiše večkratnike 3 ali 5: %s 1000 3 5\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned long int m = strtoll(argv[1], NULL, 10);
+ unsigned long int * n = malloc(sizeof(unsigned long int)*argc-2);
+ size_t i = 0;
+ size_t j = 0;
+ unsigned long int s = 0; // Seštevek
+ for (i = 0; i < argc-2; i++)
+ n[i] = strtoll(argv[i+2], NULL, 10);
+ for (i = 1; i < m; i++)
+ for (j = 0; j < argc-2; j++)
+ if (i % n[j] == 0) {
+ s = s + i;
+ break; // da štejemo samo enkrat
+ }
+ fprintf(stdout, "konec. seštevek je %ld.\n", s);
+ return 0;
+}