doc: add document for GCD and LCM function

This commit is contained in:
dudaodong committed 2023-05-06 11:28:38 +08:00
1 parent 654ba15aaf
commit e2aeb8ec07
5 files changed
+210 -8

No files matched your search

+36
View File
@@ -281,3 +281,39 @@ func ExampleIsPrime() {
// false
// true
}
func ExampleGCD() {
result1 := GCD(1, 1)
result2 := GCD(1, -1)
result3 := GCD(-1, 1)
result4 := GCD(-1, -1)
result5 := GCD(3, 6, 9)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
// Output:
// 1
// 1
// -1
// -1
// 3
}
func ExampleLCM() {
result1 := LCM(1, 1)
result2 := LCM(1, 2)
result3 := LCM(3, 6, 9)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// 1
// 2
// 18
}