Greatest common divisor of four

Write a function that computes the greatest common divisor of four natural numbers aa, bb, cc and dd using the fast version of the Euclidean algorithm.

Interface

C++,C
int gcd4(int a, int b, int c, int d);
Java
public static int gcd4(int a, int b, int c, int d);
Python
gcd4(a, b, c, d)  # returns int
gcd4(a: int, b: int, c: int, d: int) -> int

Precondition

The four numbers are strictly greater than zero.

Observation

You only need to submit the required procedure; your main program will be ignored.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-09-01T07:39:53.297Z

© Jutge.org, 2006–2026.
https://jutge.org