utils

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigMulti

func BigMulti(a, b string) string

func ExGcd

func ExGcd(a, n int) int

func Gcd

func Gcd(a, b int) int

Gcd 欧几里德算法 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理:

定理:gcd(a,b) = gcd(b,a mod b)

证明:a可以表示成a = kb + r,则r = a mod b 假设d是a,b的一个公约数,则有 d|a, d|b,而r = a - kb,因此d|r 因此d是(b,a mod b)的公约数

假设d 是(b,a mod b)的公约数,则 d | b , d |r ,但是a = kb +r 因此d也是(a,b)的公约数

因此(a,b)和(b,a mod b)的公约数是一样的,其最大公约数也必然相等,得证

func IntSliceEqualBce

func IntSliceEqualBce(a, b []int) bool

func Lcm

func Lcm(a, b int) int

func Max

func Max(nums ...int) int

func Min

func Min(nums ...int) int

func Power

func Power(a, b int) int

func Reverse

func Reverse(s string) string

func ReverseX

func ReverseX(s string) string

func ReverseXa

func ReverseXa(s string) string

Reverse s string, support unicode

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

func StringSliceEqualBce

func StringSliceEqualBce(a, b []string) bool

func StringSliceReflectEqual

func StringSliceReflectEqual(a, b []string) bool

func SumSlice

func SumSlice(res []int) int

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL