Previous Next
0 / 18
Module DEMO-32-90DEMO-C-32

GCD Calculator

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a function int gcd(int a, int b) that returns the Greatest Common Divisor of two positive integers.

Constraints

1

Input Format

Two positive integers.

Output Format

The GCD value.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
12 18
6
GCD of 12 and 18 is 6.
Sample #2
Public sample
7 13
1
Co-prime.
Sample #3
Public sample
48 18
6
GCD is 6.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings