CodeTestValidate

No installations needed! Write Python directly in your browser and get instant feedback with our smart validation system.

Challenge # 2

GCD Calculator using Euclid’s Algorithm

Objective

Compute the greatest common divisor (GCD) of two integers using the Euclidean algorithm.

Instructions

  • You are given two integer variables: a and b.

  • Use Euclid’s algorithm to find the greatest common divisor (GCD) of these two numbers.

  • Print the GCD.

Constraints:
Do not use input(). • `a` and `b` will be non-negative integers.
Exemple IO

Input: a = 48 b = 18

Output: 6

Input: a = 20 b = 8

Output: 4

Input: a = 100 b = 25

Output: 25

Try It Online!

Output:

Validate Your Results

Get your code reviewed and validated to understand what you did right and where you can improve.

Previous challengePrime Number CheckerNext challengeFibonacci Sequence Generator
Loading...