Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
Function Description
Complete the function aVeryBigSum in the editor below. It has two parameters:
n, denoting the number of elements in the input arrayar , denoting array elements whose sum needs to be computedThe function must return a long integer denoting sum of all array elements.
Problem of HankerRank: https://www.hackerrank.com/challenges/a-very-big-sum/problem
package main
import "fmt"
func main() {
var a int
var sum uint64
fmt.Scanf("%v", &a)
x := make([]uint64, a)
y := make([]interface{}, len(x))
for i := range x {
y[i] = &x[i]
}
n, _ := fmt.Scanln(y...)
x = x[:n]
sum = 0
for _, v := range x {
sum += v
}
fmt.Println(sum)
}