title: BigInteger in Groovy
body: <p>I want to add up all numbers from 1 to 1000000.</p>
  
  <pre><code>range = 1..1000000
  println range.each { it * it }.sum()
  </code></pre>
  
  <p>As a result I get 1784293664 instead of 500000500000. I assume, I need a BigInteger. But when I try</p>
  
  <pre><code>range = 1..1000000
  println range.each { it * it }.sum().toBigInteger()
  </code></pre>
  
  <p>nothing changes.  </p>
  
  <p>Where is my mistake?</p>