We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5afc68c commit 6a7d351Copy full SHA for 6a7d351
1/p1.c
@@ -0,0 +1,25 @@
1
+// Project Euler : Problem 1
2
+
3
+#include <stdio.h>
4
5
+long gcd(long a, long b);
6
7
+int main(int argc, char*argv[]) {
8
+ int args_allowed = 4;
9
+ if (argc == args_allowed) {
10
+ long mult1 = *argv[1], mult2 = *argv[2], lim = *argv[3];
11
+ if (mult1 > lim || mult2 > lim) {
12
+ printf("Argument error: the limit must be greater than both multiples.");
13
+ return -1;
14
+ } else {
15
+ printf("%l", gcd(mult1, mult2));
16
+ }
17
18
+ printf("CLI error: incorrect number of arguments supplied to the script.\n The correct number for this script is: %d", args_allowed);
19
20
21
+}
22
23
+long gcd(long a, long b) {
24
25
0 commit comments