summaryrefslogtreecommitdiffstats
path: root/mat/euler/15/prog.c
diff options
context:
space:
mode:
Diffstat (limited to 'mat/euler/15/prog.c')
-rw-r--r--mat/euler/15/prog.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mat/euler/15/prog.c b/mat/euler/15/prog.c
new file mode 100644
index 0000000..4151bfb
--- /dev/null
+++ b/mat/euler/15/prog.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+ if (argc != 1+1) {
+ fprintf(stderr, "uporaba: %s <stevilka>\nprimer za mrežo 20x20: %s 20\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned long int n = strtol(argv[1], NULL, 10);
+ unsigned long int s = 0; // Seštevek
+ unsigned long int i = 0; // Index iteracije
+ unsigned long int x = 0; // X
+ for (i = 0; i <= n-1; i++) {
+ // najprej diagonale
+ fprintf(stderr, "%lu\n", i);
+ s = s + (n-(i))+(n-(i));
+ }
+ for (i = 1; i <= n; i++) {
+ for (x = 0; x <= i-1; x++) {
+ s = s + 2*( (n-i)+(n-(x+1)) );
+ }
+ }
+ fprintf(stdout, "rezultat je: %lu\n", s);
+ return 0;
+}