Skip to content

Instantly share code, notes, and snippets.

@andersonFaro9
Created July 4, 2017 01:36
Show Gist options
  • Save andersonFaro9/792be3c0ed36fa581f6dc25fca6757bf to your computer and use it in GitHub Desktop.
Save andersonFaro9/792be3c0ed36fa581f6dc25fca6757bf to your computer and use it in GitHub Desktop.
//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