summaryrefslogtreecommitdiffstats
path: root/mat/euler/5
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-12-03 17:08:39 +0100
committersijanec <sijanecantonluka@gmail.com>2020-12-03 17:08:39 +0100
commit190507a0a05e7a6292b41bec529910ecfcbb69fb (patch)
tree20105249580655bc8b5bf47ea9ebf0e543fa06e7 /mat/euler/5
parentnaredil 8. nalogo eulerja (diff)
downloadsola-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 '')
-rw-r--r--mat/euler/5/Makefile2
-rwxr-xr-xmat/euler/5/a.outbin0 -> 8480 bytes
-rw-r--r--mat/euler/5/prog.c26
3 files changed, 28 insertions, 0 deletions
diff --git a/mat/euler/5/Makefile b/mat/euler/5/Makefile
new file mode 100644
index 0000000..2def8af
--- /dev/null
+++ b/mat/euler/5/Makefile
@@ -0,0 +1,2 @@
+default:
+ gcc prog.c
diff --git a/mat/euler/5/a.out b/mat/euler/5/a.out
new file mode 100755
index 0000000..18403da
--- /dev/null
+++ b/mat/euler/5/a.out
Binary files differ
diff --git a/mat/euler/5/prog.c b/mat/euler/5/prog.c
new file mode 100644
index 0000000..14ce34e
--- /dev/null
+++ b/mat/euler/5/prog.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+ if (argc != 1+1) {
+ fprintf(stderr, "uporaba: %s <stevilka>\nprimer: %s 20\n", argv[0], argv[0]);
+ return 1;
+ }
+ size_t i = 1;
+ size_t j = 1;
+ size_t m = atoi(argv[1]);
+ while (1) {
+ for (j = 1; j <= m; j++)
+ if (i % j != 0)
+ break;
+ else if (j >= m) {
+ fprintf(stdout, "našel: %ld\n", i);
+ return 0;
+ }
+ i++;
+ // fprintf(stderr, "debug: %ld\n", i);
+ if (i <= 1) // intager overrun
+ break;
+ }
+ fprintf(stderr, "ni bilo najdeno pred obratom števca. povečajte števec.\n");
+ return 1;
+}