I am trying to learn parameters by reference. In my code i try to compute the sum between 1 and n. This is what i got so far and if i input 5 it outputs a extremely high number. Any suggestions?

```
#include <iostream>
#include <cmath>
using namespace std;
void sum(int& n){
for (int i(1), result(0), n; i<=n ; i++){
result += i;
}
return;
}
int main(){
int result, n;
cin >> n;
sum(n);
cout << result << endl;
system("PAUSE");
return 0;
}
```