blob: f152200fa50853009326a65845796710704e186d (
plain) (
tree)
|
|
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char ** argv) {
if (argc != 1+3) {
fprintf(stderr, "uporaba: %s <max> <a> [b c d e ...]\nprimer, ki do 1000 izpiše večkratnike 3 ali 5: %s 1000 3 5\n", argv[0], argv[0]);
return 1;
}
unsigned long int m = strtoll(argv[1], NULL, 10);
unsigned long int * n = malloc(sizeof(unsigned long int)*argc-2);
size_t i = 0;
size_t j = 0;
unsigned long int s = 0; // Seštevek
for (i = 0; i < argc-2; i++)
n[i] = strtoll(argv[i+2], NULL, 10);
for (i = 1; i < m; i++)
for (j = 0; j < argc-2; j++)
if (i % n[j] == 0) {
s = s + i;
break; // da štejemo samo enkrat
}
fprintf(stdout, "konec. seštevek je %ld.\n", s);
return 0;
}
|