Reduce the Billing Ratio

Intermediate

A 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

Inputa = 12, b = 18
Output6
Inputa = 7, b = 5
Output1
Hints
  • Euclid's algorithm: replace (a, b) with (b, a mod b) until b is 0.
Anonymous Apex

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.