From ba97b8f27b9a4b79e9345b0786cbfc7e9cfba258 Mon Sep 17 00:00:00 2001 From: hamza Date: Tue, 14 Jun 2022 13:18:38 +0100 Subject: [PATCH] subject(SumArray):add readme --- subjects/arraysum/README.md | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 subjects/arraysum/README.md diff --git a/subjects/arraysum/README.md b/subjects/arraysum/README.md new file mode 100644 index 00000000..5358032a --- /dev/null +++ b/subjects/arraysum/README.md @@ -0,0 +1,41 @@ +## array-sum + +### Instructions + +Write a function that takes an array of numbers and returns the sum of all the numbers in the array. +- If the array is empty, the function should return 0. + +### Expected function + +```go +func ArraySum(numbers []int) int { + // your code here +} +``` + +### Usage + +```go +package main + +import ( + "fmt" +) + +func main(){ + fmt.Println(ArraySum([]int{1,2,3,4,5})) + fmt.Println(ArraySum([]int{})) + fmt.Println(ArraySum([]int{-1,-2,-3,-4,-5})) + fmt.Println(ArraySum([]int{-1,2,3,4,-5})) +} +``` + +and the output should be: + +```console +$ go run . +15 +0 +-15 +3 +``` \ No newline at end of file