diff options
Diffstat (limited to '')
-rwxr-xr-x | mat/advent/4/n1 | bin | 0 -> 8432 bytes | |||
-rw-r--r-- | mat/advent/4/n1.c | 22 |
2 files changed, 22 insertions, 0 deletions
diff --git a/mat/advent/4/n1 b/mat/advent/4/n1 Binary files differnew file mode 100755 index 0000000..9d59953 --- /dev/null +++ b/mat/advent/4/n1 diff --git a/mat/advent/4/n1.c b/mat/advent/4/n1.c new file mode 100644 index 0000000..157d60d --- /dev/null +++ b/mat/advent/4/n1.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +int main (int argc, char ** argv) { + if (argc != 1+2) { + fprintf(stderr, "uporaba: %s <število> <število>\nprimer-število deliteljev 3019, ki niso delitelji 2020: %s 3019 2020\n", argv[0], argv[0]); + return 1; + } + unsigned long int n = strtol(argv[1], NULL, 10); + unsigned long int o = strtol(argv[2], NULL, 10); + unsigned long int i = 0; + unsigned long int s = 0; + unsigned long int d = 0; + for (i = 1; i <= n; i++) + if (n % i == 0) { + d++; + if (o % i != 0) + s++; + } + fprintf(stdout, "števil, ki delijo %lu (=%lu), ne pa %lu, je %lu\n", n,d,o,s); + return 0; +} |