You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

829 B

gcd

Instructions

Write a function that takes two uint representing two strictly positive integers and returns their greatest common divisor. If any of the input numbers is 0, the function should return 0.

In mathematics, the greatest common divisor (GCD) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers.

Expected function

func Gcd(a, b uint) uint {

}

Usage

Here is a possible program to test your function:

package main

import (
	"fmt"
	"piscine"
)

func main() {
	fmt.Println(piscine.Gcd(42, 10))
	fmt.Println(piscine.Gcd(42, 12))
	fmt.Println(piscine.Gcd(14, 77))
	fmt.Println(piscine.Gcd(17, 3))
}

And its output :

$ go run .
2
6
7
1
$