fork download
  1. class Num {
  2. List<Integer> num
  3.  
  4. def Num() {
  5. num = [1]
  6. }
  7.  
  8. def mul(val) {
  9. def Integer overflow = 0
  10. for(i in 0..num.size()-1) {
  11. num[i] = num[i] * val + overflow
  12. overflow = num[i] / 10000
  13. num[i] = num[i] % 10000
  14. }
  15. if(overflow > 0) {
  16. num.push overflow
  17. }
  18. }
  19.  
  20. def String toString() {
  21. def txt = Integer.toString(num.last())
  22. for(i in num.size()-2..0) {
  23. txt = txt.plus(Integer.toString(num[i]).padLeft(4, "0"))
  24. }
  25. txt
  26. }
  27. }
  28.  
  29. def n = new Num()
  30.  
  31. for(f in 2..150) {
  32. n.mul(f)
  33. }
  34.  
  35. println n
Success #stdin #stdout 1.4s 388480KB
stdin
Standard input is empty
stdout
57133839564458545904789328652610540031895535786011264182548375833179829124845398393126574488675311145377107878746854204162666250198684504466355949195922066574942592095735778929325357290444962472405416790722118445437122269675520000000000000000000000000000000000000