summaryrefslogtreecommitdiffstats
path: root/mat/euler/15/prog.c
blob: 4151bfbe3c880ff98a33e774d5e029e358e0d2d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
}