My bad, I should have paid attention that you have datatypes here.

The first answer is 1955. I ran this as you have here to get that, but also wrote a quick hashcode creation for it to see how you'd do it by hand if you had to.

The greatest common divisor is more complicated. Since I don't know what this refers to by the "previous two results", I have no choice but to write a function to determine this. To do this, I used recursion, although you may also loop:

Code:

public static int getGCD(int a, int b)
{
int iResult = 0;
if (a < 0)
{
a *= -1;
}
if (b < 0)
{
b *= -1;
}
if (a == 0 || b == 1 || a == b)
{
iResult = b;
}
else if (a == 1 || b == 0)
{
iResult = a;
}
else if (a > b)
{
iResult = getGCD(b, a % b);
}
else
{
iResult = getGCD(a, b % a);
}
return iResult;
}

As for where you have to use it, I have no idea. If its referring to the results of the loop, then its a matter of capturing the last two results using a shadow. Since your code is a function, I somehow doubt that its the last two within the for loop since you would have no way to return the results.