For loop in Kotlin to print value from 10 to 1?

All QuestionsCategory: KotlinFor loop in Kotlin to print value from 10 to 1?
chetan shidling asked 4 years ago

I need short information.

1 Answers
chetan shidling answered 4 years ago

Here is the code to print values from 10 to 1 in Kotlin.
 
fun main(args : Array<String>){
var nums = 10 downTo 1

for(a in nums)
{
println(a)
}
}
 
Output:
 
10
9
8
7
6
5
4
3
2
1