Simple Prime number count (Using Kotlin)

ewillwin·2023년 3월 22일
0
post-thumbnail
post-custom-banner

fun main() {
    val name = "내 학번"        // Declare your first variable
    println("Hi, $name!")        // …and use it!
    println("Prime number under 100 is ..")
    for (i in 2..100) {           // Loop over a range from 1 to 100
        var flag = 0
        for (j in 2..i-1){
            if (i % j == 0){
           	flag = 1
            }
        }
        if (flag == 0){
        	println("$i is prime number")
        }
    }    
}
profile
💼 Software Engineer @ LG Electronics | 🎓 SungKyunKwan Univ. CSE
post-custom-banner

0개의 댓글