Skip to content

Commit c80ad40

Browse files
Euclid’s algorithm in C
1 parent f44e408 commit c80ad40

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

recursion/euclids-algorithm.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright (C) Deepali Srivastava - All Rights Reserved
3+
This code is part of DSA course available on CourseGalaxy.com
4+
*/
5+
6+
#include<stdio.h>
7+
int GCD(int a, int b);
8+
main()
9+
{
10+
int a,b;
11+
printf("Enter values for a and b : ");
12+
scanf("%d%d", &a, &b);
13+
printf("GCD of %d and %d is %d\n",a,b,GCD(a,b));
14+
}
15+
16+
int GCD(int a, int b)
17+
{
18+
if(b==0)
19+
return a;
20+
return GCD(b, a%b);
21+
}
22+
23+

0 commit comments

Comments
 (0)