Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int GCD(int, int);
- int main(){
- int a, b;
- scanf("%d %d", &a, &b);
- printf("%d\n", GCD(a, b));
- return 0;
- }
- int GCD(int a, int b){
- if(b ==0) return a;
- else return GCD(b, a%b);
- }
- //euclidean algorithm
- //basically A=BQ + R
- //GCD (A, B) = GCD(B,R)
- //GCD (A, 0) = A
- //GCD (B, 0) = B
Add Comment
Please, Sign In to add comment