You are viewing a single comment's thread. Return to all comments →
KOTLIN Code
fun main(args: Array<String>) { val t = readLine()!!.trim().toInt() for (tItr in 1..t) { val n = readLine()!!.trim().toLong() createFibonacciSum(n) } } private fun createFibonacciSum(n: Long){ var left = 0L var middle = 1L var sum = 0L var i = 0 while(i< n && (middle + left)< n){ var right = middle + left left = middle middle = right if(right % 2L == 0L) sum += right i++ } println(sum) }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
KOTLIN Code