-
-
Save zagorulkinde/c8147920cf9307eeccd93fd8cdbd85f3 to your computer and use it in GitHub Desktop.
factorial as a stream
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
class StreamTest { | |
public static long factorial(long n) { | |
return LongStream.range(1, n+1).reduce(1, (a,b) -> a*b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment