Skip to content

Commit 6a7d351

Browse files
committed
Created problem template in C, largely unfinished.
1 parent 5afc68c commit 6a7d351

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

1/p1.c

+25
Original file line numberDiff line numberDiff line change
@@ -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+
} else {
18+
printf("CLI error: incorrect number of arguments supplied to the script.\n The correct number for this script is: %d", args_allowed);
19+
return -1;
20+
}
21+
}
22+
23+
long gcd(long a, long b) {
24+
25+
}

0 commit comments

Comments
 (0)