toggle menu
KAHelpers
androidJvm
switch theme
search in API
collections
/
dev.funkymuse.collections
/
sumFromOne
sum
From
One
fun
sumFromOne
(
n
:
Int
)
:
Int
This function uses a trick by a famous mathematician, Fredrick Gauss. Algorithm is O(1).
Return
Int
Parameters
n
Int
fun
sumFromOne
(
n
:
Float
)
:
Float
fun
sumFromOne
(
n
:
Double
)
:
Double
fun
sumFromOne
(
n
:
Short
)
:
Int
fun
sumFromOne
(
n
:
Long
)
:
Long