- To print Even numbers between 1 to N

User Input: 9

Output: 2 4 6 8

```
import java.util.Scanner
fun main(args: Array<String>) {
val userInput = Scanner(System.`in`)
print("Enter your last number : ")
var num:Int = userInput.nextInt()
print("Your even numbers are : ")
for (i in 1..num-1)
if(i%2==0)print("$i ")
}
```

Enter your last number : 7 Your even numbers are : 2 4 6Program

basic

You should know first :

**Even numbers: ** Numbers perfectly divisible by 2

`(number % 2 == 0)`

So, we are using a for loop till the last number entered and check every value for even

```
for(i in 1..LastValue) {
//Check every 'i' for even, if even then print
}
```

Concept