Created
July 4, 2017 01:36
-
-
Save andersonFaro9/792be3c0ed36fa581f6dc25fca6757bf to your computer and use it in GitHub Desktop.
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
//Mais simples possível | |
fun isPrime(num:Int) :Boolean { | |
if ((num % 2) == 0 && num !== 2 || num == 1) { | |
print("Não é primo") | |
return false | |
} | |
else { | |
print("Primo") | |
return true | |
} | |
//Com lAMBDAS | |
val numbersPrimes = arrayOf(2,3,5,7,11,13,17,19,23,29,31,37)//TODOS AQUI SÃO PRIMOS | |
val primes = numbersPrimes.map { numbersPrimes-> (numbersPrimes % 2 == 0 && numbersPrimes !== 2 || numbersPrimes == 1) } | |
print("$primes") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment