scala sum of an array elements through 'while loop' : scala throws me the error whenever i try to add/sum the elements of an array through 'while loop'

i am able to get the sum by using 'for loop'

    def sum(input:Array[Int]):Int=
      {
      var i=0;
      while(i<input.length){
      sum=i+input(i);
      i=i+1;
      }
      sum
      }


    <console>:17: error: reassignment to val
       sum= (i+input(i))
          ^
    <console>:21: error: missing argument list for method 
sum Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `sum _` or `sum(_)` instead of `sum`.



i also tried with return "sum()" but i got a diff error


    <console>:17: error: reassignment to val
       sum=i+input(i);
          ^
    <console>:20: error: not enough arguments for method 
sum: (input: Array[Int])Int.
Unspecified value parameter input.sum()