Created
March 4, 2011 18:46
-
-
Save jessex/855478 to your computer and use it in GitHub Desktop.
Euler Problem 029
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
//Maps all a^b terms for lower <= b <= upper to all a for lower <= a <= upper | |
def getDistinctCount(lower:Int, upper:Int) = { | |
(lower to upper).flatMap(a => (lower to upper).map(b => BigInt(a).pow(b))) | |
.distinct.size //Return number of distinct elements | |
} | |
println(getDistinctCount(2, 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment