Created
November 29, 2016 19:34
-
-
Save btaba/857cfd103d7af7f6cf3c70e63e3837e0 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
object CracklePop { | |
def cracklePop(start: Integer, end: Integer): Unit = { | |
val cracklePopStr = new StringBuilder() | |
if (start % 3 == 0) { | |
cracklePopStr.append("Crackle") | |
} | |
if (start % 5 == 0) { | |
cracklePopStr.append("Pop") | |
} | |
if (cracklePopStr.isEmpty) println(start) | |
else println(cracklePopStr) | |
if (start < end) cracklePop(start + 1, end) | |
} | |
def main(args: Array[String]) { | |
cracklePop(1, 100) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment