Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int gcd(int a, int b){
- if (!b) return a; //if b is less than 1, return a
- else return gcd(b, a % b); // if b is positive, call the function again
- }
- int main(){
- int a, b;
- printf("Enter two integers: ");
- scanf("%d%d", &a, &b);
- printf("The GCD is %d.", gcd(a,b));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement