Medium csharp

GCD of 13 and 20

Problem

GCD using Euclid algorithm.

Hints
  • while b != 0

Your practice code

Ready — edit the code above and click Run.

Solution

using System;

class Program
{
    static void Main()
    {
        int a = 13, b = 20;
        while (b != 0) { int t = b; b = a % b; a = t; }
        Console.WriteLine(a);
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

Euclidean algorithm.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details