admin Messages 1,679 Reaction score 288 Website tehadm.ru Oct 2, 2024 #1 C-like: package main import ( "fmt" ) func main() { fmt.Println(ReverseSeq(5)) } func ReverseSeq(n int) []int { var arr []int for i := n; i >= 1; i-- { arr = append(arr, i) } return arr }
C-like: package main import ( "fmt" ) func main() { fmt.Println(ReverseSeq(5)) } func ReverseSeq(n int) []int { var arr []int for i := n; i >= 1; i-- { arr = append(arr, i) } return arr }
admin Messages 1,679 Reaction score 288 Website tehadm.ru Oct 2, 2024 #2 C-like: func ReverseSeq(n int) []int { ans := []int{} for n > 0 { ans = append(ans, n) n-- } return ans }
C-like: func ReverseSeq(n int) []int { ans := []int{} for n > 0 { ans = append(ans, n) n-- } return ans }