summaryrefslogtreecommitdiffstats
path: root/mat/euler/5/prog.c
blob: 14ce34e7ce9832b99f397f05b9fbffaf48f968cf (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
25
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;
}