diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-12-09 12:28:12 +0100 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-12-09 12:28:12 +0100 |
commit | 98b9e121256ecf8faa32f8ab1fbbbc665d808d8a (patch) | |
tree | 9b3c9b3ec37b19d150b07480600ff3f6566754f5 /mat/advent/4/n1.c | |
parent | euler 17 + izdelovalec angleških številk s črkami iz številk (diff) | |
download | sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar.gz sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar.bz2 sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar.lz sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar.xz sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.tar.zst sola-gimb-2-98b9e121256ecf8faa32f8ab1fbbbc665d808d8a.zip |
Diffstat (limited to 'mat/advent/4/n1.c')
-rw-r--r-- | mat/advent/4/n1.c | 22 |
1 files changed, 22 insertions, 0 deletions
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; +} |