A Very Big Sum Solution in Kotlin -HackerRank

  • int ar[n]: an array of integers .
  • long: the sum of all array elements
5
1000000001 1000000002 1000000003 1000000004 1000000005
5000000015

ANSWER

fun aVeryBigSum(ar: Array<Long>): Long {var total: Long = 0  ar.forEach { it ->
total += it
}
return total}

--

--

--

Hey curious person, I am Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Great prevent far either hit benefit.

Streamline IoT projects with Infrastructure as Code

Microsoft OpenHacks - why they are the great way to improve your technical skills

Make Giant HD BlenderGIS Mosaic/Map, then export that as a usable flat textured 2d Map

CS371p Spring 2021: Michael Liu

RoadToWebDev Day#2 — HTTP/HTTPS and APIs

EKS — Connecting to the cluster

10 VS Code extensions every Web Developer should use!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Umar Syaid Himawan

Umar Syaid Himawan

Hey curious person, I am Software Developer

More from Medium

The Philosophy of ViewModel

Testing Dialogs in Robolectric

Use AWS CodeArtifact in your project.

Ideas and Solutions for Advent of Code 2021 in Kotlin — Part 3/4