- 1
Make a program that take N as input and calculates the sum of all consecutive number from 1 to N inclusive.
You can iterate over a range and calculate the sum of all numbers in the range. Remember, range(a, b) does not include b, thus you need to use b+1 to include b in the range.
2 Answers
+ 3
elly paul
Your code please?
0
fun main() {
var n = readLine()!!.toInt()
print((1..n).asSequence().sum())
}