title: Why type mismatch error?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7395682/scala-immutable-variables-and-printing">Scala immutable variables and printing</a>  </p>
  </blockquote>
  
  
  
  <p>I am confused why this will not run as i expect it to, I have tried to change it multiple times and it still give an error stating that it is given <code>Unit</code> and needs <code>Int</code>.</p>
  
  <pre><code>def div(m: Int, n: Int): Int = {
    var counter = 0
    var p = m 
    while (p &gt;= 0) {
      p -= n
      counter += 1
      println(counter)
    }
  }
  </code></pre>