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