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.
lavos/cap3/ex36.go

21 lines
296 B

7 months ago
package cap3
func Ex36(num int) []int {
// 用另外一种写法,直接存能整除的数
divNums := make([]int, 0)
if num%3 == 0 {
divNums = append(divNums, 3)
}
if num%5 == 0 {
divNums = append(divNums, 5)
}
if num%7 == 0 {
divNums = append(divNums, 7)
}
return divNums
}