You are viewing a single comment's thread. Return to all comments →
I cannot pass 2 of the tests with this Kotlin code, anybody has any idea?
fun main(args: Array<String>) { val t = readLine()!!.trim().toInt() for (tItr in 1..t) { val n = readLine()!!.trim().toInt() println("${sumn(n,3)+sumn(n,5)-sumn(n,15)}") } } fun sumn(n:Int,d:Int):Int{ val l = (n-1)/d return d*l*(l+1)/2 }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
I cannot pass 2 of the tests with this Kotlin code, anybody has any idea?