# Kotlin Program to print all prime numbers between 1 to n

In this program, You will learn how to print all prime numbers between 1 to n in Kotlin.

`Some list of prime numbers is : 2, 3, 5, 7, 11, 13`

## Example: How to print all prime numbers between 1 to n in Kotlin.

```
import java.util.Scanner
fun main(args: Array<String>) {
var n: Int
var sc = Scanner(System.`in`)
print("Enter a number:")
n = sc.nextInt()
for (i in 2..n) {
var p = 1
var k = 2
while (k < i) {
if (i % k == 0) {
p = 0
break
}
k++
}
if (p == 1) {
println("Number is prime:$i")
}
}
}
```

#### Output:

```
Enter a number:13
Number is prime:2
Number is prime:3
Number is prime:5
Number is prime:7
Number is prime:11
Number is prime:13
```