// num_torture.cm — integer math torture test
// Pure integer arithmetic so it stays on the fast int path.
// Returns the final checksum so the caller can verify correctness.

var n = 5000000
var sum = 0
var i = 0
var a = 0
var b = 0

while (i < n) {
  a = (i * 7 + 13) % 10007
  b = (a * a) % 10007
  sum = (sum + b) % 1000000007
  i = i + 1
}

return function(n) {
  var i = 0
  var a = 0
  var b = 0
  var sum = 0
  while (i < n) {
    a = (i * 7 + 13) % 10007
    b = (a * a) % 10007
    sum = (sum + b) % 1000000007
    i = i + 1
  }

  return sum
}
