summaryrefslogtreecommitdiffstats
path: root/mat/euler/6
diff options
context:
space:
mode:
Diffstat (limited to 'mat/euler/6')
-rw-r--r--mat/euler/6/Makefile2
-rwxr-xr-xmat/euler/6/a.outbin0 -> 8472 bytes
-rw-r--r--mat/euler/6/prog.c20
3 files changed, 22 insertions, 0 deletions
diff --git a/mat/euler/6/Makefile b/mat/euler/6/Makefile
new file mode 100644
index 0000000..156bc0d
--- /dev/null
+++ b/mat/euler/6/Makefile
@@ -0,0 +1,2 @@
+default:
+ gcc prog.c -lm
diff --git a/mat/euler/6/a.out b/mat/euler/6/a.out
new file mode 100755
index 0000000..07b6490
--- /dev/null
+++ b/mat/euler/6/a.out
Binary files differ
diff --git a/mat/euler/6/prog.c b/mat/euler/6/prog.c
new file mode 100644
index 0000000..5a17cea
--- /dev/null
+++ b/mat/euler/6/prog.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main (int argc, char ** argv) {
+ if (argc != 1+1) {
+ fprintf(stderr, "uporaba: %s <koliko>\nprimer: %s 100\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned long int i = 1;
+ unsigned long int m = atoi(argv[1]);
+ unsigned long long int s = 0;
+ unsigned long long int z = 0;
+ for (i = 1; i <= m; i++) {
+ s = s + pow(i, 2);
+ z = z + i;
+ }
+ z = pow(z, 2);
+ fprintf(stdout, "konec. %lld - %lld = %lld\n", z, s, z-s);
+ return 0;
+}