Reduce the Billing Ratio
Intermediate SolvedA billing module reduces ratios to their simplest form before display. The first step is finding the greatest common divisor of two positive integers.
Implement `solve(Integer a, Integer b)` to return the greatest common divisor of two positive integers.
Examples
Input
a = 12, b = 18Output
6Input
a = 7, b = 5Output
1Hints
- Euclid's algorithm: replace (a, b) with (b, a mod b) until b is 0.
Tests
Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.