diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-12-03 17:08:39 +0100 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-12-03 17:08:39 +0100 |
commit | 190507a0a05e7a6292b41bec529910ecfcbb69fb (patch) | |
tree | 20105249580655bc8b5bf47ea9ebf0e543fa06e7 /mat/euler/1 | |
parent | naredil 8. nalogo eulerja (diff) | |
download | sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.gz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.bz2 sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.lz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.xz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.zst sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.zip |
Diffstat (limited to 'mat/euler/1')
-rw-r--r-- | mat/euler/1/Makefile | 2 | ||||
-rwxr-xr-x | mat/euler/1/a.out | bin | 0 -> 8480 bytes | |||
-rw-r--r-- | mat/euler/1/prog.c | 23 |
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 Binary files differnew file mode 100755 index 0000000..abe5144 --- /dev/null +++ b/mat/euler/1/a.out 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; +} |