Created
November 6, 2017 09:07
-
-
Save IEnoobong/4a7ba0c24907289f1872d632d684a6a0 to your computer and use it in GitHub Desktop.
Before you go all functional
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
val sum = (0 until Integer.MAX_VALUE) | |
.map { it.toLong() } | |
.sum() | |
println(sum) |
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
val sum = (0 until Integer.MAX_VALUE) | |
.asSequence() | |
.map { it.toLong() } | |
.sum() | |
println(sum) |
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
var sum = 0L | |
for (i in 0..Integer.MAX_VALUE - 1) { | |
sum += i | |
} | |
println(sum) |
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
var sum = 0L | |
for (i in 0 until Integer.MAX_VALUE) { | |
sum += i | |
} | |
println(sum) |
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
Long sum = 0L; | |
for (long i = 0; i < Integer.MAX_VALUE; i++) { | |
sum += i; | |
} | |
System.out.println(sum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment