Created
October 16, 2023 22:07
-
-
Save sasssass/13935b3a083ffdc6ecb61caac6e462a2 to your computer and use it in GitHub Desktop.
Declarative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sumOfEvenNumbers(numbers: List<Int>): Int { | |
return numbers.filter { it % 2 == 0 }.sum() | |
} | |
fun main() { | |
val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) | |
val result = sumOfEvenNumbers(numbers) | |
println("Sum of even numbers: $result") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment