Created
August 11, 2012 10:56
-
-
Save daiksy/3323803 to your computer and use it in GitHub Desktop.
素数のときにJoJo
This file contains hidden or 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
object jojo extends App { | |
def isPrime(n: Int) = { | |
if (n < 2) { | |
false | |
} else { | |
(2 to n - 1).exists(n % _ == 0) == false | |
} | |
} | |
0 to 100 map {i => | |
if (isPrime(i)) { | |
"JoJo" | |
} else { | |
i | |
} | |
} foreach println | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment