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.
24 lines
437 B
24 lines
437 B
package cap3
|
|
|
|
func Ex37(n int) []int {
|
|
var coeff func(nums []int, n int)
|
|
coeff = func(nums []int, n int) {
|
|
if n <= 0 {
|
|
return
|
|
}
|
|
|
|
// 第一个和最后一个数字肯定是1
|
|
nums[0] = 1
|
|
coeff(nums, n-1)
|
|
nums[n] = 1
|
|
|
|
for i := n - 1; i > 0; i-- {
|
|
nums[i] += nums[i-1]
|
|
}
|
|
}
|
|
|
|
nums := make([]int, n+1)
|
|
coeff(nums, n)
|
|
|
|
return nums
|
|
}
|
|
|