advanced code snippet search
marcospereira on 12/22/08
factorial sum bigdecimal idiomatic
12/22/08 11:45am
import static java.math.BigInteger.ONE def factorial2(BigInteger n) { def answer = ONE for (i=BigInteger.ONE; i<=n; i++) { answer *= i } return answer} def sumDigits(BigInteger n) { def digitString = n.toString() def digits = digitString.collect { it.toBigInteger() } return digits.sum() }
Report this snippet Tweet
Comment:
You need to login to post a comment.