1 2 3 4 5 6 7 8 9 10 11
import java.util.stream.IntStream; public class _Math { static int factorial(int num){ if(num == 0 || num == 1) return 1; return IntStream.rangeClosed(1, num).reduce((a,b) -> a*b).getAsInt(); } }
styled using hilite.me
No comments:
Post a Comment